WAC0020
WAC0020

Reputation: 379

Need help with jqGrid and navGrid

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.

Upvotes: 0

Views: 8908

Answers (3)

Jose R
Jose R

Reputation: 804

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,

Upvotes: 1

Oleg
Oleg

Reputation: 221997

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'
    }
}

Upvotes: 1

Lorenzo
Lorenzo

Reputation: 29427

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; 
        }
    }, 
    {},
    {}
);

Upvotes: 0

Related Questions