MVC kendo window - Get Data from javascript function

六月ゝ 毕业季﹏ 提交于 2019-12-06 07:53:16

If you really need to access your data via the JavaScript getInfo() function, then the way to do this is to define the Window as you are doing but don't set the content until you open the window. When opening the Window, use jQuery.ajax() to call CopyResult, passing the results of getInfo() into the data parameter.

In your Razor, take out LoadContentFrom add an event handler for the Open event:

@(Html.Kendo().Window()
    .Name("copyStructure")
    // Omitted for brevity
    ...
    .Events(e => e.Open("copyStructure_Open"))
)

And in your handler in JavaScript, call $.ajax and in the success callback, call the content method on the Window object passing the returned data as the parameter:

function copyStructure_Open(e) {
    $.ajax({
        url: '@Url.Action("CopyStructure", "NewXmlLayout")',
        type: 'POST',
        data: getInfo(),
        success: function(data) {
            e.sender.content(data);
        }
    });
}

Beware to only send what's required for the window content, and not a full page (DOCTYPE, html, head, body) - see this documentation from Telerik: http://docs.telerik.com/kendo-ui/getting-started/web/window/overview#loading-window-content-via-ajax

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!