views:

70

answers:

1

I'm using the ASP.NET wrapper for JqGrid. I'd like to programmatically wire up handlers for some of the grid's events (e.g. gridComplete, resizeStop).

All the examples I've seen have you wire up the event as part of the options when creating the grid object - for example:

$("#gridid").jqGrid({
   ...
   onSelectRow: function(){ ... },
   ...
});

However, the ASP.NET component does this initial setup for me. I can customize some client-side handlers on the component, like gridInitialized; but (bizarrely) only a small subset of the events are exposed this way.

So: Once the grid has initialized, is there a way to attach handlers to its events? I've tried things like

$grid.setGridParam("resizeStop", function () { alert("!!") }); // DOESN'T WORK

and

$grid.resizeStop = function () { alert("!!") }; // DOESN'T WORK

and of course the standard jQuery event binding syntax

$grid.bind("resizeStop", function () { alert("!!") }) // DOESN'T WORK

but none of this works.

Any ideas?

A: 

You can do change event handler with respect of setGridParam method (see a close question http://stackoverflow.com/questions/3148320/add-an-event-handler-to-jqgrid-after-instantiation/3149534#3149534). It must work on the same way for commertial and for the open source version of jqGrid. Just try following:

$('#gridid').jqGrid('setGridParam', { resizeStop: function(newwidth, index) {
    alert("The column with the index " + index + " has now the width " + newwidth);
} } );
Oleg