4

Apologies if this question has been answered before.

Though the answers I've seen look correct according to jqGrid documentation, I have been completely unable to get the "editData" parameter of "editGridRow" to work.

I've tried setting editData through "navGrid" edit options:

$("#myGrid").jqGrid(
  "navGrid",
  "#pager",
  {edit:false,add:false,del:false}, //options
  {editData:{myparam:function(){return "myval"}}}, // edit options
  {}, // add options
  {}, // del options
  {} // search options
  );

and through "editGridRow":

$("#myGrid").jqGrid('editGridRow',rowid, {
   editData:{myparam:function(){return "myval"}},
   height:240,
   reloadAfterSubmit: true,
   editCaption:'Edit Record',
   bSubmit:'Save',
   url:'someurl.php',
   closeAfterEdit:true,
   viewPagerButtons:false
});

My additional POST data is just NOT showing up on POST.

Any idea what I may be doing wrong?

Thanks!

jrockway
  • 42,082
  • 9
  • 61
  • 86
blitzn
  • 63
  • 1
  • 4

1 Answers1

5

You are right. It's a bug in the line

postdata = $.extend(postdata,rp_ge.editData,onCS);

of jqGrid 4.1.2 which should be

postdata = $.extend(postdata,rp_ge[$t.p.id].editData,onCS);

If one makes the modification in the jquery.jqGrid.src.js all become to work correctly. See the demo.

By the way I could find the fix. So the bug is already fixed in the jqGrid code from the github.com.

Oleg
  • 220,925
  • 34
  • 403
  • 798
  • 2
    StackOverflow has been a valuable resource for me for quite some time now, but I only joined when I had a critical issue I could not find an answer to - and as I had hoped, Oleg was on it. jqGrid is a fine piece of software and I appreciate your help on this bug. Not only that, I've been highly impressed with the great answers (mostly from Oleg) to other jqGrid questions on StackOverlow. I really did look around the net for quite a while before resorting to adding a question here. You rock Oleg! – blitzn Jul 27 '11 at 13:56
  • 1
    @blitzn: You are welcome! And thank you for good words which you wrote! – Oleg Jul 27 '11 at 14:22
  • Code (ver.4.4.1) from trirand.com still has this bug. Is it better idea to always use the source form github? – ymakux Nov 19 '12 at 10:53
  • @volocuga: You can verify that `jquery.jqGrid.src.js` of jqGrid 4.4.1 contains the line `postdata = $.extend(postdata,rp_ge[$t.p.id].editData,onCS)`. So I can't confirm the existence of the bug in jqGrid 4.4.1. – Oleg Nov 19 '12 at 11:11
  • Yep, you right I downloaded the master branch on github. I found that fix but still can't get it working. Created issue at github https://github.com/tonytomov/jqGrid/issues/385 – ymakux Nov 19 '12 at 11:56
  • 1
    @volocuga: the demo which you posted use wrong option `editData`. You should `inlineData` instead or `extraparam` in case that you use inline editing. See [the answer](http://stackoverflow.com/a/8512693/315935) and [another one](http://stackoverflow.com/a/13035492/315935). – Oleg Nov 19 '12 at 12:01
  • 1
    @volocuga: You can consider to set data like token inside of HTTP header. You can use `setRequestHeader` inside of `loadBeforeSend` (see [the answer](http://stackoverflow.com/a/5706690/315935)). Inline editing don't have any `loadBeforeSend`, but you can define `beforeSend` callback of `$.ajax` inside of `ajaxRowOptions`. – Oleg Nov 19 '12 at 12:28
  • I solved my problem by this code $.extend($.jgrid.edit, { editData: {feeds_editor_token:"' . get_token() . '"}, // get_token() is a PHP function to generate a random string reloadAfterSubmit: true, closeAfterEdit:true, viewPagerButtons:false, }); Not sure if this is the right way, but at least it works form me – ymakux Nov 19 '12 at 14:16
  • Thanks Oleg, best support I ever seen :) – ymakux Nov 19 '12 at 14:18