Question

so i am working with the navigation bar and I add this code to the delete options

onclickSubmit: function (options, rowid) {
    var rowData = jQuery(this).jqGrid('getRowData', rowid);
    var params ={amount:rowData.amount,account:rowData.account.replace(/-/g,"")};

    return params;
},

and it works just fine. now when i add the same to edit options, it does not work ! when i try an alert(rowData.account) it shows undefined ! while at the same time, the same alert with the same parameter in delete options displays the correct value !

can anyone figure out whats going on here. right now i have to muse the following code in edit options

onclickSubmit: function (/*options, rowid, rowObject*/) {

    //var roData = jQuery(this).jqGrid('getRowData', 8);
    var s;

    s = jQuery("#list").jqGrid('getGridParam','selarrrow');
    var dataF = jQuery('#list').jqGrid ('getCell', s[0], 'account');

    return {account:dataF.replace(/-/g,"")};
},

i get really confused whenever i see these examples showing parameters like options, rowid, rowObject being passed. some examples pass 2 parameters while others pass 3 while others pass none at at all and all of their code works !

and how do we know that say, options is a keyword or not. what about rowid ? some people use rowId and that works too !

Is there any documentation which explains:

1) type and number of parameters for each jqGrid function

2) keywords or reserved words for jqGrid functions

i have a big presentation coming up and they will grill me for sure. i have no idea how the jqGrid works or why it does what it does because the behavior of most jqgrid functions is so erratic. Maybe I feel this way as I am a newbie but please if someone can throw some light on these issues i would be very grateful

thanks

Was it helpful?

Solution

It's a little uncomfortable, but the onclickSubmit of form editing has no rowid parameter. You can get it from postdata:

onclickSubmit: function (options, postdata) {
    var rowid = postdata[this.id + "_id"]; // postdata.list_id
    ...
}

By the way to be exactly the second parameter of onclickSubmit in case of Delete operation is also postdata which is rowid only if musltiselect: true option is not set or if selected only one row. If multiselect: true are used and more as one row selected to delete then postdata will be comma separated string with ids of deleting rows (see the documentation).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top