如何以编程方式处理JqGrid事件?

编程入门 行业动态 更新时间:2024-10-23 17:34:43
本文介绍了如何以编程方式处理JqGrid事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

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方法进行更改事件处理程序(请参见在实例化后将事件处理程序添加到jqGrid ).对于商业版本和jqGrid的开源版本,它必须以相同的方式工作.只需尝试以下操作:

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事件?

本文发布于:2023-11-07 11:17:33,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1566303.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:事件   方式   JqGrid

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!