How to handle a JqGrid event programmatically?

牧云@^-^@ 提交于 2019-12-23 22:05:20

问题


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?


回答1:


You can do change event handler with respect of setGridParam method (see a close question Add an event handler to jqGrid after instantiation). 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);
} } );


来源:https://stackoverflow.com/questions/3358927/how-to-handle-a-jqgrid-event-programmatically

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!