asp.net-mvc - 如何在 MVC Grid 的 Kendo UI 中从自定义命令重定向用户?

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

我有一个用于 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/

相关文章:

javascript - 选择所有分页并显示每页结果,同时使用 JQuery 禁用和启用按钮

c# - Chrome 没有传递参数而是获取 AuthResend

c# - 在 MVC3 中添加控件 ID 前缀以确保唯一性。发回服务器时我丢失了所有数据

asp.net-mvc - 如何在 ASP.NET MVC 中使用 Razor 布局作为母版页

html - TextBoxFor 不考虑文本中的换行、回车

c# - 从 ASP.NET MVC Controller 中删除功能

javascript - momentjs 显示本地时间和自动格式字符串

ajax - 在 jquery-ajax 函数之后提交

asp.net - 带条件的 Linq 计数

c# - 如何设置asp.net身份默认登录页面