如何检索单个请求colmodel和数据,加快负荷的jqGrid [英] how to retrieve colmodel and data on single request and speed up jqgrid load

查看:251
本文介绍了如何检索单个请求colmodel和数据,加快负荷的jqGrid的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

jqGrid的是由ASP .NET MVC2应用程序的远程JSON数据供电。
在页面加载两个请求被发送到服务器:一个检索与colmodel整个HTML页面和第二援引的jqGrid检索数据。

jqGrid is powered by remote json data in ASP .NET MVC2 application. On page load two requests are sent to server: one to retrieve whole html page with colmodel and second invoked by jqgrid to retrieve data.

colmodel被存储在数据库中,并取决于用户的权利和用户配置。创建colmodel需要它需要一段时间的SQL Server的呼叫号码。

colmodel is stored in database and depends on user rights and user configuration. Creating colmodel requires number of sql server calls which take a while.

这两个请求,要求服务器构建colmodel。对于数据检索colmodel需要得到列的正确数量来构建select语句。

Both request require building colmodel in server. For data retrieval colmodel is required to get correct number of columns to build select statement.

目前此colmodel是建立两次为每个请求。还需要recods总数要返回这是对大数据慢(导致PostgreSQL服务器整个结果扫描)。

Currently this colmodel is built two times for every request. Also total number of recods is required to be returned which is slow on large data (causes whole result scan in PostgreSql server).

如何加快东西?
如何建立col​​model只有一次,把它和数据在相同的请求?

How to speed the things up ? How to build colmodel only once and send it and data in same request?

推荐答案

我同意的jqGrid该分机,以支持每个的有一个 colModel 的某些部分的加载的阿贾克斯将是非常有益的。大约一年我张贴<一个href=\"http://www.trirand.com/blog/?page_id=393/feature-request/filling-jqgrid-parameters-like-colmodel-per-ajax/#p22758\"相对=nofollow>例如功能要求。

I agree that extension of jqGrid to support the loading of some parts of colModel per one Ajax will be very helpful. For about a year I posted the feature request for example.

您现在可以做什么:


  1. 如果我正确理解你的要求,你需要为用户显示的子集的的列取决于用户的权限。一个可以实现的有一个的Ajax请求的要求。你可以做的是:先不发了隐藏的数据或将那里作为空字符串。秒就可以发送列,这应该被隐藏的名单,给客户端。在这种情况下,你可以实现可变数量的jqGrid列。您可以发送例如JSON响应的用户数据部分内的信息。有许多隐藏的列更好的表现,我会建议你打电话给 showCol hideCol beforeProcessing 和隐藏/显示在空格<列/ em>的。这将加快 showCol hideCol 显着的性能。如果它可以根据需要包括附加的呼叫 clearGridData

  2. 您必须优化检索 colModel 。我不明白为什么它应该是缓慢的。一切都取决于您的实现。以任何方式,我相信,人们可以使检索真的很快。

  3. 要提高从可以考虑JSON响应的不填写记录字段中输入数据库的数据请求的性能和设置 + 1 即可。它enebles寻呼机的下一步按钮。你应该设置等于仅在返回更少的行为(每页行数)。在大多数情况下,这将是很好的标准来检测的最后一页。你还可以隐藏在湖寻呼机领域的一些最后按钮和 SP_1 _... 跨度,显示的页面总数。您可以通过 pgtext的使用做到这一点:页面{0}选项或 pginput的用法:假有没有寻呼机输入的。在 viewrecords (默认值)。所有的定制后,您将不必计算总记录数和方式提高大量数据的情况下,数据库请求的性能。

  1. If I correct understand your requirements you need to show the user the subset of the columns depend on the user's permissions. One can implement the requirement in one Ajax request. What you can do is: first don't send the "hidden" data or send there as empty string. Seconds you can send the list of columns, which should be hidden, to the client. In the case you can implement the variable number of columns in jqGrid. You can send the information inside of userData part of JSON response for example. To have better performance with many hidden columns I would recommend you to call showCol or hideCol inside of beforeProcessing and hide/show the columns on the empty grid. It will speed up the performance of showCol or hideCol dramatically. If it's needed you can include additional call of clearGridData.
  2. You have to optimize the retrieval colModel. I don't understand why it should be slow. All depends from your implementation. In any way I am sure that one can make the retrieval really quickly.
  3. To improve the performance of request of data from the database you can consider don't fill records field of the JSON response and set total to page + 1. It enebles the "Next" button of the pager. You should set total equal to page only if you returns less rows as the rows (number of rows per page). In the most cases it will be good criteria to detect the last page. You can additionally hide some field on the pager lake the "Last" button and the sp_1_... span which shows the total number of pages. You can do this by the usage of pgtext : "Page {0}" option or the usage of pginput: false to have no pager input at all. The viewrecords should be false (its default value). After all the customization you will don't need to calculate the total number of records and in the way improve performance of the database request in case of large data.

这篇关于如何检索单个请求colmodel和数据,加快负荷的jqGrid的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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