【问题标题】:How to make popup window footer unscrollable如何使弹出窗口页脚不可滚动
【发布时间】:2015-06-02 14:00:20
【问题描述】:

我的项目中有一个 Kendo 窗口,并在其中填充了一些字段。尽管标题按我的意愿行事,但滚动条溢出到页脚。我希望窗口内容是可滚动的,除了下图所示的页眉和页脚(页脚可见为粘性)。我该怎么做?

查看:

@(Html.Kendo().Window()
    .Name("winCreate")
    .Title("New")
    .Visible(false)
    .Draggable(true)
    .Content("Loading...")
    .LoadContentFrom("Create", "Issue")
    .Modal(true) 
    .Actions(actions => actions
        .Close()
     )      
)



@using (Html.BeginForm("Create", "Issue", FormMethod.Post}))
{
    @Html.AntiForgeryToken()

<div class="container">

    @Html.LabelFor(m => m.ProjectID)
    @Html.TextBoxFor(m => m.ProjectID, new { maxlength = 75, @class = "k-textbox" })
    <br />

    ... //The other staff here

    <div class="modal-footer">
        @(Html.Kendo().Button()
        .Name("btnCancel")
        .HtmlAttributes(new { type = "button", @class = "k-button" })
        .Content("Cancel")
        .Events(ev => ev.Click("closeWindow"))
        )

        @(Html.Kendo().Button()
        .Name("btnSubmit")
        .HtmlAttributes(new { type = "submit", @class = "k-primary k-button"            })
        .Content("Save")
    )
    </div>

</div>
}

【问题讨论】:

    标签: css asp.net-mvc html kendo-ui kendo-asp.net-mvc


    【解决方案1】:

    创建一个调整内容 div 大小的函数:

      function ResizeDialog(){
        var h = $("#dialog").height();
        var headH = $("#dialog .modal-header").outerHeight(true);
        var footH = $("#dialog .modal-footer").outerHeight(true);
        var contH = h - headH - footH ;
    
        $("#dialog .container").height(contH).css("overflow", "auto");    
      }
    

    然后在窗口打开和调整大小时调用这个函数:

    $("#dialog").kendoWindow({
      title: "New",
      draggable: true,
      modal: true,
      height: "80%",
      resize: function() {
        ResizeDialog();
      },
      open: function() {
        ResizeDialog();
      }
    });
    

    工作DEMO

    注意,DEMO没有使用MVC,但基本做法应该是一样的……

    【讨论】:

    • 我还没有想到这种用javascript设置css属性的方法。非常好,谢谢...
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-12-26
    • 1970-01-01
    • 1970-01-01
    • 2015-12-16
    • 2023-04-06
    • 2022-06-15
    相关资源
    最近更新 更多