【问题标题】:How to redirect user from custom command in Kendo UI for MVC Grid?如何从 MVC Grid 的 Kendo UI 中的自定义命令重定向用户?
【发布时间】:2012-08-11 00:54:55
【问题描述】:

我有一个用于 MVC 的 Kendo Grid,并且我在每一行都添加了一个自定义命令。现在我需要连接 click 事件以使用所选行中的 ID 值将用户重定向到另一个视图。

按原样工作,但 ID 是硬编码的。我需要动态构建重定向的帮助:

 function editShippment() {


var grid = $('#Grid').data('kendoGrid');   //get a reference to the grid data 
var record = grid.dataItem(grid.select()); //get a reference to the currently selected row
var shippingHeaderID = record.ShippingHeaderID;
window.location.href = "@Url.Action("ShippingLineItemsEdit","Shipping",new {id= 182})"; //hard coded but need the record.ShippingHeaderID inserted here.  
 }

【问题讨论】:

  • 将自定义命令添加到行的代码在哪里?
  • columns.Command(command => command.Custom("Edit").Click("editShippment")).Width(40);

标签: asp.net-mvc asp.net-mvc-3 razor kendo-ui


【解决方案1】:

使用 Url.Action 帮助器构建主 url,然后附加 id。

window.location.href = "@Url.Action("ShippingLineItemsEdit","Shipping")" 
                       + "/" + shippingHeaderID; 

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-10-24
    • 2017-02-16
    • 1970-01-01
    • 2013-10-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多