2

我试图在单击按钮事件时才在剑道窗口中加载视图。实际上,每次加载基本页面时都会显示弹出窗口。我希望该弹出窗口仅在按钮的单击事件上加载。

我错过了什么吗?我还在 html 按钮中添加了 onclick 事件并调用了 openWindow() javascript 方法。但它也没有工作,显然有问题。

是否可以将下面的 kendo Window 的服务器代码放在 jquery 函数中?如果是,如何?

<% Html.Kendo().Window()
      .Name("partListGridWindow")
      .Width(800)
.......
%>

这是我的代码 JQuery:

$(document).ready(function () {
   $("#partListLink")
        .bind("click", function () {
            $("#partListGridWindow").data("kendoWindow").open().center();
        });
});

kendo 窗口:在 LoadContentFrom 中,我调用 PartList,它是从 Claim Controller 返回我的视图的操作名称。

<% Html.Kendo().Window()
               .Name("partListGridWindow")
               .Width(800)
               .Modal(true)
               .Title("Part List Info")
               .Content("Loading Part List Info...")
               .LoadContentFrom("PartList", "Claim", Model)
                //.Visible(false)
               .Draggable()
               .Resizable()
               .Render();
%>

这是html按钮:

<a id="partListLink" class="k-button" onclick=openWindow()></a>

顺便说一句,我在 Telerik 论坛上看到他们推荐这个公式来隐藏带有Visible = false的窗口,但它应该是一种在基本页面加载开始时绕过这些窗口负载的方法。

如果要加载数十个或更多弹出窗口,该怎么办?

任何帮助是极大的赞赏!非常感谢您的帮助!

4

2 回答 2

2

如果在基本页面加载时您的 Kendo 窗口正在填充,您必须设置 .Visible(false). 这就是我们在之前的项目中所做的。

这是点击事件

function clientLaunchWindow() {

     var window = $("#Window").data("kendoWindow");

     window.refresh({
             url: "/Order/LaunchWindow"        
     });      
     window.center();
     window.open();

你的控制器只会返回部分视图

public ActionResult LaunchWindow()
    {
       return PartialView("_PartialView");
    }
于 2014-04-02T14:28:18.867 回答
1

你好伙伴我非常了解你的问题。剑道的默认功能似乎是通过其基本页面加载来加载内容。您应该添加内容而不是 LoadcontentFrom 链。并定义一个 div 并为此设置一个 id。在按钮单击功能中,您应该执行 ajax 调用并获取内容并加载到您为 div 设置的 id 中。

<% Html.Kendo().Window()
               .Name("partListGridWindow")
               .Width(800)
               .Modal(true)
               .Title("Part List Info")
               .Content(@<text>
                <div id="WindowContent"> </div> </text>)
               .Visible(false)
               .Draggable()
               .Resizable()
               .Render();
%>

你的按钮是:

function openWindow(e) {
        var GridWindow = $("#partListGridWindow");
        GridWindow.data("kendoWindow").open().center();

    $.ajax({
        type: "GET",
        url: '@Url.Action("LaunchWindow", "Controller")',
        cache: false,
        data: { "x": 1 },

                success: function (result) {
                    if (result) {

                        $("#WindowContent").html(result);
                    }
                    else {
                        $("#WindowContent").html(<h2>No Content found</h3>)
                    }
                }
            });
}
于 2018-12-20T19:37:14.600 回答