在实例化后向jqGrid添加一个事件处理程序 [英] Add an event handler to jqGrid after instantiation

查看:146
本文介绍了在实例化后向jqGrid添加一个事件处理程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为jqGrid添加一个事件处理程序(对于onSelectRow事件),但在页面上已经创建了网格之后,即我不能将其硬编码到初始的jqGrid定义中。

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.

我已尝试使用 setGridParam onSelectRow 设置事件处理程序,但没有工作:(

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

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

jqGrid文档很难得到你想要的东西,我没有发现有关这个问题的任何事情。

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

推荐答案

我刚刚测试使用

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

在我的代码中,它的工作原理如果jqGrid已经有一个 onSelectRow ,它将覆盖旧的一个事件句柄,如果没有 onSelectRow 事件处理程序,它会添加一个新的处理程序,所以都必须工作。

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.

这篇关于在实例化后向jqGrid添加一个事件处理程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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