我有一个用于 MVC 的 Kendo 网格,并且我已向每一行添加了一个自定义命令。现在,我需要连接单击事件,以使用所选行中的 ID 值将用户重定向到另一个 View 。
这按原样工作,但 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.
}
最佳答案
使用 Url.Action
帮助器构建主 url,然后附加 id。
window.location.href = "@Url.Action("ShippingLineItemsEdit","Shipping")"
+ "/" + shippingHeaderID;
关于asp.net-mvc - 如何在 MVC Grid 的 Kendo UI 中从自定义命令重定向用户?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11957272/