jqGrid - 网格初始化时的事件 [英] jqGrid - event on grid initialization

查看:636
本文介绍了jqGrid - 网格初始化时的事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用jquery jqGrid插件,我需要在网格初始化时触发事件。我测试了 gridComplete loadComplete 事件,但这些事件在每个服务器请求之后引发。我需要一个在栅格初始化之后提升的事件。我阅读了 jqGrid活动列表,但我看不到任何相关事件符合我的要求。有什么办法吗感谢您的关注。



更新:



感谢@Oleg为他回答。我使用jqGrid 4.6,并使用@ Oleg的建议事件与这种模式:

  $('#grid1')。jqGrid 'setGridParam',{
onSelectRow:function(id){
//这个事件没有问题提出
},
onInitGrid:function(){
//
},
jqGridInitGrid:function(){
//这个事件没有提高
},
});

但这不工作。使用这两个事件的正确方法是什么?

解决方案

如果我正确理解您的需求,jQuery事件 jqGridInitGrid onInitGrid 回调是你需要的。这是第一个事件/回调,在构建jqGrid的外部部分之后,以及在首次使用数据填充jqGrid之前,将在创建网格期间调用一次事件/回调。事件/回调可用于jqGrid 4.6 / 4.7



新版本的我现在开发的免费jqGrid 另外还包含 beforeInitGrid 回调和 jqGridBeforeInitGrid 事件。回调/事件将在 jqGrid开始处理输入参数之前调用。所以有可能使参数的任何修改。您可以根据输入数据修改/生成 colModel



所以最好的回调/事件取决于初始化的时刻,您需要进行一些更改,以及您使用的jqGrid版本。


I'm using jquery jqGrid plugin and I need to fire event on grid initialization. I tested gridComplete and loadComplete events, but these events raised after every server request. I need an event that raise just once and after initialization of the grid. I read jqGrid events list, but I don't see any related event to my requirement. Is there any way? Thanks for your attention.

Update:

Thanks to @Oleg for his answer. I'm using jqGrid 4.6 and used @Oleg's suggested events with this pattern:

  $('#grid1').jqGrid('setGridParam', {
                onSelectRow: function(id) {
                    //This event raised without problem.
                },
                onInitGrid: function(){
                  //This event does not raised.
                },
                jqGridInitGrid: function(){
                  //This event does not raised.
                },
            });

But this is not working. What is the correct way to use these two events?

解决方案

If I understand your requirements correctly the jQuery event jqGridInitGrid or onInitGrid callback is what you need. It's the first events/callbacks which will be called once during creating the grid after the outer part of jqGrid will be constructed and before the first filling of jqGrid with data. The event/callback can be used in jqGrid 4.6/4.7

The new version of free jqGrid, which I'm developing now, contains additionally beforeInitGrid callback and jqGridBeforeInitGrid event. The callback/event will be called before jqGrid start processing of input parameters. So it's possible for example make any modification of the parameter. You can for example modify/generate colModel based on the input data.

So the best choice of the callbacks/events depend on at what moment of initialization you need to do some changes and from which version of jqGrid you use.

这篇关于jqGrid - 网格初始化时的事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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