I have this kendo window in my app
Html.Kendo().Window()
.Name("copyStructure")
.Title("Copy Structure")
.Content("Loading...")
.LoadContentFrom("CopyStructure", "NewXmlLayout") // <-- here*
.Draggable(false)
.Visible(false)
.Modal(true)
.Actions(s => s.Custom(""))
.Events(e => e.Open("openWindow").Close("closeWindow"))
And I am trying to pass data to the action in the LoadContentFrom() which is returned by a JavaScript function, but I don't know how to do it. I can pass data like this:
.LoadContentFrom("CopyStructure", "NewXmlLayout", new { type= "INPUT" })
But is not what I'm looking for.
The JS function:
function getInfo() {
return { type: "INPUT" };
};
My controller:
public ActionResult CopyStructure(string type)
{
return PartialView();
}
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