13

I want to add an event handler to jqGrid (for the onSelectRow event) but after the grid has already been created on the page i.e. I cant hardcode it into the initial jqGrid definition.

I have tried using setGridParam to set an event handler for onSelectRow but that didnt work :(

$('#list').jqGrid('setGridParam', { onSelectRow: function(id){ alert(id); } } );

The jqGrid docs are quite difficult to get what you want out of them and I havent found anything regarding this problem.

Jimbo
  • 22,379
  • 42
  • 117
  • 159

1 Answers1

20

I just tested to use

$('#list').jqGrid('setGridParam', { onSelectRow: function(id){ alert(id); } } );

in my code and it works. If jqGrid has already an onSelectRow it overwrite the old one event handle. If there are no onSelectRow event handler, it add a new handler. So all must work.

If you do will have problem, you should post a code example which reproduce it.

Oleg
  • 220,925
  • 34
  • 403
  • 798
  • Hi Oleg - perhaps my version of jQuery? Its working now with exactly the same code, i was playing with different versions of jQuery at the time tho. Thanks for the confirmation anyway :P – Jimbo Jul 08 '10 at 08:07
  • @Oleg, is there a way to register multiple functions to be called on a grid event? For example, I want some basic stuff to always run on loadComplete, but on some grids I have other stuff that belongs there as well. – IronicMuffin Jul 21 '11 at 13:11
  • @IronicMuffin: It's a good question! There are only one `loadComplete` event. If you describe more exactly your environment and your problem one can suggest the solution. – Oleg Jul 21 '11 at 13:23
  • @Oleg, I asked it with a little more detail [here](http://stackoverflow.com/questions/6776696/is-it-possible-to-bind-multiple-event-handlers-to-jqgrid-events-without-overwriti). – IronicMuffin Jul 21 '11 at 13:27
  • Yet again, Oleg to the rescue! Thanks again, Oleg! – FastTrack Aug 28 '13 at 19:52