loadComplete和gridComplete事件有什么区别? [英] What the difference between loadComplete and gridComplete events?

查看:542
本文介绍了loadComplete和gridComplete事件有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题是在我查看这个 Oleg 和演示网格。



gridComplete


所有数据加载到网格中并且所有其他
进程完成后,将触发。另外事件也是独立于
数据类型参数,排序分页等功能。


loadComplete


每个服务器请求后立即执行此事件。数据
来自响应的数据取决于数据类型网格参数


从该文档中我了解到 gridComplete 在绘图网格结束时触发,并且jqGrid完成与后端的通信后, loadComplete 触发。



所以我不知道为什么在演示中, loadComplete 用于更改单元格的颜色,而不是 gridComplete

解决方案

我认为这个问题是由jqGrid的许多用户提出的。所以有趣的是要知道答案。



我个人更喜欢使用 loadComplete 。如果您检查我发布的所有示例中的代码,只有当原始海报发布在问题中时,您才会找到 gridComplete ,并且我将修改一些代码。因为 loadComplete 的一些优势,而且$ code> gridComplete loadComplete c $ c>。



这里有 loadComplete 的优点:




  • 如果整个网格主体将被重新加载,这将是最后一个回调。例如从服务器上加载网格上的页面。重要的是要了解,如果用户更改某些列或集的排序过滤器或选择网格的另一个页面;网格体将被重新加载。

  • loadComplete 具有参数数据



另一边 gridComplete 将从内部 updatepager 调用(在当前版本的jqGrid 4.4.4中)(请参阅 here ),其中将从 delRowData (请参阅此处 ), addRowData (请参阅 here )和 clearGridData (见 here )方法;另外 addXmlData (请参阅 here )和 addJSONData (见 here )。这不是最想要的。



gridComplete 的另一个缺点是可以看到是否检查 addXmlData (请参阅这里)和 addJSONData (请参阅 here updatepager 被调用,所以 gridComplete 将被调用。如果使用 loadonce:true 和内部参数数据 _index 将填充从服务器返回的完整数据。使用 loadonce:true ;在从服务器加载数据的第一页之后,将调用回调 gridComplete 。此时,数据 _index 仅包含页面的数据。另一方面,从服务器返回的所有数据在数据中被处理并保存在本地之后将会调用loadCplete / code>和 _index



如果从服务器加载数据,请使用 loadonce:true 选项, clearGridData addRowData delRowData 然后你可以使用 gridComplete 而不是 loadComplete 。 / p>

This question originated after I looked on this answer of Oleg and demo-grids in it.

gridComplete:

This fires after all the data is loaded into the grid and all other processes are complete. Also the event fires independent from the datatype parameter and after sorting paging and etc.

loadComplete:

This event is executed immediately after every server request. data Data from the response depending on datatype grid parameter

From that docs I understood that gridComplete fires at the end of drawing grid, and loadComplete fires after jqGrid completes communication with backend.

And so I wonder - why in demos, loadComplete used for change color of cells and not gridComplete?

解决方案

I think that this question is asked by many users of jqGrid. So it's interesting to know the answer.

I personally prefer to use loadComplete. If you examine code from all my examples which I posted, you will find gridComplete only when the Original Poster posted it in the question and I would have modified a little code. I prefer to use loadComplete because of some advantages of loadComplete and disadvantages of gridComplete.

Here are advantages of loadComplete:

  • It's the last callback which will be called if the whole grid body will be reloaded. For example after loading the page on the grid from the server. It's important to understand, that if the user changes sorting of some column or sets filter or chooses another page of the grid; the grid body will be reloaded.
  • loadComplete has parameter data which represent full page of local data or full data loaded from the server.

On the other side gridComplete will be called (in the current version of jqGrid 4.4.4) from internal updatepager (see here), which will be called from delRowData (see here), addRowData (see here) and clearGridData (see here) methods; in addition to addXmlData (see here) and addJSONData (see here). It's not what one mostly want.

Another disadvantage of gridComplete one can see if one examines the code of addXmlData (see here) and addJSONData (see here) from where updatepager is called and so gridComplete will be called. If one uses loadonce: true and the internal parameters data and _index will be filled with full data returned from the server. One can see when using loadonce: true; the callback gridComplete will be called after the first page of data are loaded from the sever. At this moment data and _index contains only the data for the page. On the other side loadComplete will be called later after all data returned from the server are processed and saved locally in data and _index.

If you load the data from the server and if you don't use loadonce: true option, clearGridData, addRowData and delRowData then you could use gridComplete instead of loadComplete.

这篇关于loadComplete和gridComplete事件有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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