I suppose that you have the problem with the order of processing of click
event.
The first problem is in registering of additional click
event handler. Why you do this? jqGrid already registered one click
event handler. jqGrid process it and it calls beforeSelectRow
callback, trigger jqGridBeforeSelectRow
event then it selects the row, it calls onSelectRow
callback, trigger jqGridSelectRow
event, calls onCellSelect
callback, trigger trigger jqGridCellSelect
. In other words jqGrid process click
event and allows to use callbacks and events to do some additional actions, which synchronized with internal work of jqGrid.
If you register the second click
handler then you could not quarantine that your click
handler will be called after the row of the grid is selected.
I recommend you to use callback or events described above. Moreover you use setSelection
in the code fragment which you posted. On the other side it's not clear how you fill the grid. You can call setSelection
only after the corresponding row will be inserted in jqGrd. I suppose that your real code is another. Nevertheless the code which you posted can't work. Moreover the code defines i
variable inside of onSelectRow
callback, but you try to use it in outside of the callback. In the case i
will be undefined
forever.
grid.setSelection(i,true);
code insideonSelectRow :
handler? – Totemism