0

With the main part of the jqGrid there is the postData parameter that can be set to add stuff to the POST variable. Is there a way I could do the same thing with the navGrid?

Here is what I have:

main jqGrid script

    $("#"+id).jqGrid({
        url:baseURL+'modules/'+module+'/config.php',
        postData: {event: 'load-content',content : id,module: module},
        datatype: 'json',
        mtype: 'POST',
        colNames:colNames,
        colModel:colModel,
        pager: '#pager',
        rowNum:limit,
        rowList:[10,20,30],
        autowidth: true,
        sortname: sortby,
        sortorder: 'desc',
        gridview: true,
        viewrecords: true,
        caption: title,
        editurl: baseURL+'modules/'+module+'/config.php'
    });

navGrid script

jQuery("#"+id).jqGrid('navGrid','#pager',
    {del:true,add:true,edit:true}, //options
    {height:280,reloadAfterSubmit:false}, // edit options
    {height:280,reloadAfterSubmit:false}, // add options
    {reloadAfterSubmit:false}, // del options
    {});

What I want is to add {module: module, event: 'del-test'} to the POST of the delete button.

Lorenzo
  • 29,081
  • 49
  • 125
  • 222
WAC0020
  • 379
  • 1
  • 11
  • 27

3 Answers3

1

You can use additional editData (for add or edit operations) or delData parameter (for delete operation) and change the del options used as a parameter of 'navGrid' from

{reloadAfterSubmit:false}

to

{reloadAfterSubmit:false, editData:{module: module, event: 'del-test'}}

(the variable module should be defined before).

By the way, like with postData parameter (see this old answer) you can use function for any property of editData parameter:

{
    reloadAfterSubmit:false,
    delData: {
        module: function() {
            return "bla bla";
        },
        event: 'del-test'
    }
}
Community
  • 1
  • 1
Oleg
  • 220,925
  • 34
  • 403
  • 798
  • I tried the editData but it still does not send the module and event variables. – WAC0020 Nov 26 '10 at 19:35
  • @WAC0020: Sorry, of cause for the delete operation the name of parameter must be `delData` (see http://www.trirand.com/jqgridwiki/doku.php?id=wiki:form_editing#properties2). Parameter `editData` are used only in add or edit operation. I'll change the text of my answer. – Oleg Nov 26 '10 at 19:50
1

I know it's a long time since you posted this question, I wanted to improve it anyways the wiki pages shows you the basic use of the navgrid and this is the answer that worked for me.

Best regards,

Community
  • 1
  • 1
Jose R
  • 738
  • 2
  • 10
  • 26
0

Modify your code this way

$("#" + id).jqGrid('navGrid', '#pager',
    { add: true, edit: true, del: true },
    { height:280, reloadAfterSubmit:false },
    { height:280, reloadAfterSubmit:false },
    {
        // settings for Delete 
        mtype: "post",
        reloadAfterSubmit: false,
        onclickSubmit: function (rp_ge, postdata) {
            rp_ge.url = '<%: Url.Content("~/URL/TO/DELETE/METHOD/HERE") %>' + postdata;
        },
        serializeDelData: function (postdata) { 
           postdata.module = module;
           postdata.event = 'del-test';
           return postdata; 
        }
    }, 
    {},
    {}
);
Lorenzo
  • 29,081
  • 49
  • 125
  • 222