我正在使用:VS 2010,ASP.NET MVC2,jqGrid 3.8.2。jqGrid navGrid按鈕調用ASP.NET MVC視圖 - 如何?
我想讓navGrid的'編輯'按鈕在控制器中打開不同的視圖。我嘗試過很多事情都無濟於事。爲了打開選定的行,我假設我需要將該id附加到url。
jQuery('#listComponents').jqGrid({
url: '/Components/Get',
editurl: '/Components/Edit',
...
}).navGrid('#pagerComponents', {edit:true, ...}, {url: '/Components/Edit'});
歡迎任何建議。如果我無法使用它,我會在jqGrid外部添加一個'編輯'按鈕,並執行一個普通的Html.ActionLink調用來打開不同的視圖。
謝謝!
更新
繼@奧列格的回答,我現在有以下工作完美:
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.");
}
}});
謝謝你給我一個我無法解決的問題的答案。這節省了我很多時間。完美工作。 – 2011-03-15 03:17:25