【发布时间】:2011-07-14 06:44:34
【问题描述】:
我正在使用:VS 2010、ASP.NET MVC2、jqGrid 3.8.2。
我想让 navGrid 的“编辑”按钮在控制器中打开不同的视图。我尝试了很多事情都无济于事。为了打开选定的行,我假设我需要将 id 附加到 url。
jQuery('#listComponents').jqGrid({
url: '/Components/Get',
editurl: '/Components/Edit',
...
}).navGrid('#pagerComponents', {edit:true, ...}, {url: '/Components/Edit'});
欢迎提出任何建议。如果我不能让它工作,我将在 jqGrid 之外添加一个“编辑”按钮,并执行正常的 Html.ActionLink 调用以打开不同的视图。
谢谢!
更新
按照@Oleg 的回答,我现在可以完美地完成以下工作:
jQuery('#listComponents').jqGrid(
{
url: '/Components/Get/',
...
}).navGrid('#pagerComponents', { edit: false, ...})
.navButtonAdd('#pagerComponents', {
caption: "",
title: "Edit Component",
buttonicon: "ui-icon-pencil",
onClickButton: function () {
var id = jQuery("#listComponents").getGridParam('selrow');
if (id) {
var data = jQuery("#listComponents").getRowData(id);
window.location = '/Components/Edit/' + data.COMPONENTID;
}
else {
alert("Please select a row to edit.");
}
}});
【问题讨论】:
标签: asp.net-mvc jqgrid