EvanWeeks
EvanWeeks

Reputation: 31

Kendo UI Window.refresh({ data }) not being passed to ASP.Net MVC action properly

I have a window:

@(Html.Kendo().Window()
   .Name("wndInvoiceLineEditor")
   .Title("Invoice Line Item Editor")
   .Content("loading dialog...")
   .Height(350)
   .Width(785)
   .LoadContentFrom("InvoiceLineItemEditor", "Invoice", new { LineItemId = "Initial" })
   .Draggable()
   .Resizable()
   .Visible(false)
)

I need to be able to re-load that partial view, with different data passed along at runtime. As far as I read in the documentation, I should be able to do this:

$("#wndInvoiceLineEditor").data("kendoWindow").refresh({
   data: {
      LineItemId: $($(".k-state-selected td")[0]).text()
   }
});

However the action server-side:

public ActionResult InvoiceLineItemEditor(string LineItemId)
{
   int id = 0;
   if(string.IsNullOrEmpty(LineItemId) || !int.TryParse(LineItemId, out id))
   { 
      return PartialView("InvoiceLineItemEditorPartial", new InvoiceLineItem());
   }

   ...blah blah blah

...doesn't receive the proper ID (the jquery to grab it from the table DOES work, has been tested via Chrome console)

Instead, it receives the data as configured in the view: "Initial".

Am I missing something? How do I get the data sent back to the action so I can load that partial with the right information?

ANSWERED:

The problem was the default data being set up in the LoadContentFrom part of the window initialization in the view. Changing it to:

@(Html.Kendo().Window()
   .Name("wndInvoiceLineEditor")
   .Title("Invoice Line Item Editor")
   .Content("loading dialog...")
   .Height(350)
   .Width(785)
   .LoadContentFrom("InvoiceLineItemEditor", "Invoice")
   .Draggable()
   .Resizable()
   .Visible(false)
)

...fixes the problem. The window was set, seemingly immovably, to that default value.

Upvotes: 2

Views: 2332

Answers (1)

EvanWeeks
EvanWeeks

Reputation: 31

The problem was the default data being set up in the LoadContentFrom part of the window initialization in the view. Changing it to:

@(Html.Kendo().Window()
   .Name("wndInvoiceLineEditor")
   .Title("Invoice Line Item Editor")
   .Content("loading dialog...")
   .Height(350)
   .Width(785)
   .LoadContentFrom("InvoiceLineItemEditor", "Invoice")
   .Draggable()
   .Resizable()
   .Visible(false)
)

...fixes the problem. The window was set, seemingly immovably, to that default value.

Upvotes: 1

Related Questions