用kendo网格点击事件关闭Kendo窗口?

时间:2014-02-04 13:24:44

标签: kendo-window

有一个功能打开一个带有局部视图(带有剑道网格)的kendo窗口作为内容,如下所示:

$('#CodUnePai').keydown(function (event) {
        if (event.keyCode == 115) {
            event.preventDefault();
            var myWindow = $("#dialog").kendoWindow({
                actions: ["Minimize", "Maximize", "Close"],
                content: {
                    url: '@Url.Action("BSfunePartial","BSfune")',
                },
                draggable: true,
                height: "300px",
                width: "300px",
                modal: false,
                position: {
                    top: 300,
                    left: 1200
                },
                resizable: true,
                title: "Unidades de Negócio",
                visible: false
            });
            $("#dialog").data("kendoWindow").center();
            $("#dialog").data("kendoWindow").open();
        }
    });

我点击网格时将数据传递给我的CodUnePai:

$("#BSfunePartialGrid").click(function (e) {
    var selectedItem = e.target.innerText;
    this.ownerDocument.forms.FormCreate.CodUnePai.value = selectedItem;
});

但我也想关闭窗口。如何在网格的单击或双击事件中执行此操作?你能帮我吗?谢谢。:)

1 个答案:

答案 0 :(得分:0)

你可以通过2种方式来实现

通过添加close in action

的第一种方式
$("#termWindow").kendoWindow({
                    modal: true,
                    visible: false,
                    resizable: true,
                    width: "700px",
                    title: "TopUp - Terms & Condition",
                    actions: [
                        "Pin",
                        "Minimize",
                        "Maximize",
                        "Close"   

                    ]

                });

第二,在模板中添加关闭按钮并调用关闭功能

<div id="dialog"></div>
<script type="text/x-kendo-template" id="MessageBoxTemplate">
        <div id="MessageBox-container">
            <em>#= Message # </em>
            <div style="text-align:center">
                <input type="button" id="btnclose" name="btnclose" value="Close" onclick="closeMessageBox()">    
            </div>
        </div>
 </script>

//Close Function MessageBox
        function closeMessageBox(e)
        {
            $("#MessageBox").data("kendoWindow").close();
        }