jqGrid navGrid button calling ASP.NET MVC view - how?

前端 未结 1 1449
日久生厌
日久生厌 2020-12-17 05:19

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

相关标签:
1条回答
  • 2020-12-17 05:53

    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';
          }
        }
    );
    
    0 讨论(0)
提交回复
热议问题