如何以编程方式处理JqGrid事件? [英] How to handle a JqGrid event programmatically?

查看:52
本文介绍了如何以编程方式处理JqGrid事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 JqGrid的ASP.NET包装器.我想以编程方式为某些事件(例如gridCompleteresizeStop).

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(){ ... },
   ...
});

但是,ASP.NET组件会为我执行此初始设置.我可以在组件上自定义一些客户端处理程序,例如gridInitialized;.但是(很少)以这种方式公开了事件的一小部分.

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

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

当然还有标准的jQuery事件绑定语法

and of course the standard jQuery event binding syntax

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

但是这些都不起作用.

but none of this works.

有什么想法吗?

推荐答案

您可以针对setGridParam方法进行更改事件处理程序(请参见

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);
} } );

这篇关于如何以编程方式处理JqGrid事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆