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

查看:20
本文介绍了实例化后向 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.

我曾尝试使用 setGridParamonSelectRow 设置事件处理程序,但这不起作用:(

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天全站免登陆