I am using: VS 2010, ASP.NET MVC2, jqGrid 3.8.2.
I want to have the navGrid \'Edit\' button open a different view in the controller. I have tried a number of things
The option {edit:true, ...}
of the navGrid follow to the usage of editGridRow method of the form editing, so the dialog will be displayed and not the View of your MVC controller. To have the behavior which you want you should use {edit:false, ...}
setting and add custom button which look exactly like the original "Edit" button. To make this you should use buttonicon: "ui-icon-pencil"
parameter (see editicon
default parameter in the navGrid
source code). In this answer you will find code example. You can additionally use $.jgrid.nav.edittitle
as the title parameter:
var grid = $("#listComponents");
grid.jqGrid({
url: '/Components/Get',
editurl: '/Components/Edit',
...
});
grid.navGrid('#pagerComponents', {edit:false, ...}, ...);
grid.jqGrid ('navButtonAdd', '#pagerComponents',
{ caption: "", buttonicon: "ui-icon-pencil", title: $.jgrid.nav.edittitle,
onClickButton: function() {
var rowid = grid.jqGrid('getGridParam', 'selrow');
window.location = '/Components/Edit/' + 'rowid';
}
}
);