单击按钮时,kendo窗口不关闭

时间:2017-03-07 18:49:16

标签: asp.net-mvc-5 kendo-grid kendo-contextmenu kendo-ui-window

我创建了一个在kendo窗口中渲染的视图。我在视图上有取消按钮。我想关闭窗口当我单击取消按钮时。我已经编写了代码来完成它。但似乎没有任何事情发生。

请参阅下面的代码和屏幕截图

enter image description here

Kendo窗口代码

setInterval

在道格窗口中呈现的视图

  $("#contextMenu").kendoContextMenu({
            target: "#grid",
            alignToAnchor: false,
            select: function (e) {
                var selectedItem = e.item; // check this item is add or edit and then open the kendo window

                if ($(selectedItem).text() == 'Add' || $(selectedItem).text() == 'Edit') {
                    var accessWindow = $("#addEdit").kendoWindow({
                        actions: {}, /*from Vlad's answer*/
                        draggable: true,
                        height: "700px",
                        modal: true,
                        resizable: false,
                        title: "Add new User",
                        width: "800px",
                        visible: false,


                    }).data("kendoWindow").center().open();

                    $("#btnCancel").click(function () {
                        $(this).closest("[data-role=window]").data("kendoWindow").close();
                    });

                    $("#language").kendoDropDownList({
                        filter: "startswith",
                        dataTextField: "LanguageDescription",
                        dataValueField: "LanguageCode",
                        dataSource: language
                        //dataSource: {

                        //    type: "odata",
                        //    serverFiltering: true,
                        //    transport: {
                        //        read: {
                        //            url: "https://demos.telerik.com/kendo-ui/service/Northwind.svc/Products",
                        //        }
                        //    }
                        //}
                    });

                    $("#country").kendoDropDownList({
                        filter: "startswith",
                        dataTextField: "CountryDescription",
                        dataValueField: "CountryCode",
                        dataSource: country
                        //dataSource: {

                        //    type: "odata",
                        //    serverFiltering: true,
                        //    transport: {
                        //        read: {
                        //            url: "https://demos.telerik.com/kendo-ui/service/Northwind.svc/Products",
                        //        }
                        //    }
                        //}
                    });



                }
            }
        });

1 个答案:

答案 0 :(得分:0)

这已经解决了。我不得不添加以下jquery来修复它

   $("#btnCancel").click(function () {
                                $(this).closest("[data-role=window]").data("kendoWindow").close();
                            });