0

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

Oleg
  • 220,925
  • 34
  • 403
  • 798
AbtPst
  • 7,778
  • 17
  • 91
  • 172

1 Answers1

0

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).

Oleg
  • 220,925
  • 34
  • 403
  • 798
  • so what exactly is postdata ? is it aan array of all the data that would be passed to the server ? and what about options ? options is the most annoying as I can never figure out what it is ! thanks for all your help and patience @oleg – AbtPst Jul 12 '13 at 15:15
  • @user2334092: The `options` parameter of `onclickSubmit` is object which saves the options of `editGridRow` (the second parameter of `editGridRow`). The initial `options` of `editGridRow` will be a little modified and the current state of the options you can access in `onclickSubmit` for example. You can for example modify `url` here to access RESTful service which required to have `id` as part of URL of Edit operation instead of sending it as part of reques body. `postdata` build mostly the body of the message with will be send to the server. – Oleg Jul 12 '13 at 15:22
  • @user2334092: See [the answer](http://stackoverflow.com/a/17258545/315935) or [this one](http://stackoverflow.com/a/7365228/315935) for more information about the usage of `options`. – Oleg Jul 12 '13 at 15:24
  • so, are options and postdata keywords ? what about rowObject and rowid ? i just want to know whether these are predifened keywords in jqgrid or a user can name them anything and the first parameter will always be treated as 'options' ? – AbtPst Jul 12 '13 at 15:27
  • @user2334092: It's just the names of parameters. `keywords` can exist only in the computer language (like `if` or `else`). I can't answer what it `rowObject` and ehich exactly format it has. You should post exact name of callback which you mean. `rowid` is mostly the value of `id` attribute of the grid row (of `` element of the ``). You can choose *any* name of parameters of your callback functions. It's better to use the name which more corresponds to the *actual* parameters of the callback.
    – Oleg Jul 12 '13 at 15:32
  • i can understand, thats what makes it so confusing. i'll do some more digging into the documentaion. thanks @oleg ! – AbtPst Jul 12 '13 at 15:41
  • @user2334092: You are welcome! I would recommend you to use `jquery.jqGrid.src.js` instead of `jquery.jqGrid.min.js` and **debug jqGrid code**. In the way you can better understand the implementation of jqGrid. [The source](https://github.com/tonytomov/jqGrid) of jqGrid on github is another good place. One more good source are code fragments from old stackoverflow answers. I post frequently the demo which you can debug and better understand how all works on the example. – Oleg Jul 12 '13 at 15:45