【问题标题】:Kendo UI Window.refresh({ data }) not being passed to ASP.Net MVC action properlyKendo UI Window.refresh({ data }) 未正确传递给 ASP.Net MVC 操作
【发布时间】:2015-03-19 15:53:40
【问题描述】:

我有一个窗口:

@(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)
)

我需要能够重新加载该部分视图,并在运行时传递不同的数据。据我在文档中阅读,我应该能够做到这一点:

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

但是动作服务器端:

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

...没有收到正确的 ID(从表中抓取它的 jquery 确实有效,已通过 Chrome 控制台测试)

相反,它接收视图中配置的数据:“初始”。

我错过了什么吗?如何将数据发送回操作,以便我可以使用正确的信息加载该部分?

回答:

问题在于视图中窗口初始化的 LoadContentFrom 部分中设置的默认数据。将其更改为:

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

...解决问题。窗口被设置为该默认值,看似不可移动。

【问题讨论】:

  • 请将您的解决方案写成您的问题的可接受答案,否则这个问题是否有解决方案并不是很明显。

标签: jquery asp.net-mvc kendo-ui kendo-asp.net-mvc kendo-window


【解决方案1】:

问题是视图中窗口初始化的 LoadContentFrom 部分中设置的默认数据。将其更改为:

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

...解决问题。窗口被设置为该默认值,看似不可移动。

【讨论】:

    猜你喜欢
    • 2014-08-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-28
    • 2013-09-01
    • 2013-06-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多