javascript - jqGrid onCellSelect getGridParam selrow returning null on first click -


i using jqgrid , on first click of cell, null sel_id:

 function oncellselect(rowid, icol, cellcontent, e) {         var downlinkindex = 7;         var uplinkindex = 8;         var salcodeindex = 3;          if (icol == downlinkindex) {             var grid = jquery('#salespersonlist');             var sel_id = grid.jqgrid('getgridparam', 'selrow');             var mycelldata = grid.jqgrid('getcell', sel_id, 'salespersonid');             var mysalname = grid.jqgrid('getcell', sel_id, 'name');             showdownlink(mycelldata, mysalname);         }         if (icol == uplinkindex) {             var grid = jquery('#salespersonlist');             var sel_id = grid.jqgrid('getgridparam', 'selrow');             var mycelldata = grid.jqgrid('getcell', sel_id, 'salespersonid');             var mysalname = grid.jqgrid('getcell', sel_id, 'name');             showuplink(mycelldata, mysalname);         }     } 

the event method being fired. 4 parameters being populated. on first click, null. on 2nd click, set first click. 3rd click set 2nd click. oleg, if can help, appreciate it.

after reading bunch of oleg's posts. moved code other function onbeforeselect.

function onbeforeselectrow(rowid, e){     console.log(rowid);     console.log(e);      var grid = jquery('#salespersonlist');     icol = $.jgrid.getcellindex($(e.target).closest("td")[0]),         cm = grid.jqgrid("getgridparam", "colmodel");      console.log(cm);     if (cm[icol].name === "uplines") {         var mycelldata = grid.jqgrid('getcell', rowid, 'salespersonid');                 var mysalname = grid.jqgrid('getcell', rowid, 'name');                 showuplink(mycelldata, mysalname);               return true;         }     if (cm[icol].name === "downlines") {         var mycelldata = grid.jqgrid('getcell', rowid,  'salespersonid');                 var mysalname = grid.jqgrid('getcell', rowid,  'name');                 showdownlink(mycelldata, mysalname);                     return true;         }       return false;  } 

some tweaks needed since no longer being passed cell. understanding code more, bet of used rowid parameter passed oncellselect.

i tried that, , yes, (using rowid in oncellselect) works.


Comments

Popular posts from this blog

Django REST Framework perform_create: You cannot call `.save()` after accessing `serializer.data` -

Why does Go error when trying to marshal this JSON? -