Kendo window refresh does not work

Viewed 6432

I am stuck at what appears to be a very simple scenario: Loading a Kendo window with a partial view bound to a model, with a dynamic parameter modelId that will be provided by client side js.

I found out about the refresh() method, but this implies that there is already a kendo window intialized. That's the first problem. I need the the modelId to display content. So I worked around this issue and simply returned a new model intially which than should be replaced/refreshed by the refresh() method + a valid parameter modelId and finally be displayed. Problem: The view won't be updated. The refresh() method actually works, though. The controller receives the parameter modelId, fetches the corresponding model and returns the view. But the Kendo window still holds the empty viewmodel instead.

I tryed really hard to get this to work but without success..

@(Html.Kendo().Window()
      .Name("window")
      .Title("")
    //loads an empty viewmodel intially as there is no possibility to pass parameter
      .LoadContentFrom("Actionname", "Controller")          
      .Actions(actions => actions.Close())
      .Modal(true).Visible(false)
      .HtmlAttributes(new {style = "margin: 10px"})
      )

Javascript snippet:

$("#window").data("kendoWindow").refresh({
    url: '/controller/actionname/',
    data: { parameterlabel: parameter}
});
$("#window").data("kendoWindow").open().center(true);
3 Answers

First time I saw this issue with:

wnd.refresh({
    url: msg.Url,
    type: "POST",
    contentType: "application/json", 
    dataType: "json",
    data: msg.Data
});

and the Kendo Window was empty. The request in Fiddler (some headers and data removed):

POST http://localhost/My/PtsSchedule/Pts_AddBooking HTTP/1.1
Accept: application/json, text/javascript, */*; q=0.01
Content-Type: application/json

The problem was apparently in:

Accept: application/json, text/javascript, /; q=0.01

and removing dataType: solved the issue for me. Here the new refresh:

wnd.refresh({
    url: msg.Url,
    type: "POST",
    contentType: "application/json", 
    data: msg.Data
});

and in Fiddler:

POST http://localhost/My/PtsSchedule/Pts_AddBooking HTTP/1.1
Accept: text/html, */*; q=0.01
Content-Type: application/json

and the content was displayed within the Kendo Window. Hope this is from help.

Related