Reputation: 27945
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 is stored in database and depends on user rights and user configuration. Creating colmodel requires number of sql server calls which take a while.
Both request require building colmodel in server. For data retrieval colmodel is required to get correct number of columns to build select statement.
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).
How to speed the things up ? How to build colmodel only once and send it and data in same request?
Upvotes: 0
Views: 556
Reputation: 221997
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.
What you can do now:
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
.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.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.Upvotes: 1