In our project, we are using jqgrid to display records. hibernate as orm tools.in our database there will be 1000s of rows are there and we don't want to get them in one request cause I if we do so then slow downs the website response.so we decided to go for pagination But we don't know how to implement jqgrid pagination with Struts2 and Hibernate.
Asked
Active
Viewed 853 times
0
-
The code you need to do pagination. – Roman C Jan 17 '15 at 14:12
-
could you include more information about the grid which you create. Which `datatype` you use? do you use `gridview: true` option? Do you use `loadonce: true` option for client side paging (one need it only if you use `datatype: "json"` or `datatype: "xml"`)? – Oleg Jan 19 '15 at 07:53
1 Answers
0
jqgrid supports client side and server side paging. For 1000 records I suggest server side paging, please see:
http://struts.jgeppert.com/struts2-jquery-grid-showcase/index.action

Alireza Fattahi
- 42,517
- 14
- 123
- 173
-
client side paging can works very good with even more as 1000 rows if one uses correct options. Look at [the demo](\\diskstation\Documents\Oleg\jqGrid\StackOverflow\performane-90000__.htm) which generate 90000 rows of data and uses 20 rows page size. You can try to go to the next/previous/first/last pages and the performance is very good. The total time in ms of loading the 90000 rows in the grid will displayed at the opening of the page. See [the answer](http://stackoverflow.com/a/26121503/315935). If one uses jqGrid 4.7.0 no tricks are required. – Oleg Jan 19 '15 at 07:50
-
I did not know that performance result, thanks! According to question it seems that retrieving 1000 data slows down the server, so it is better to get records 20 by 20 (from DB) and pass them to client. OT: The struts jquery pluin 3.71. uses jqGrid 4.6.0, and due to license update it seems that they can not update jqGrid any more https://github.com/struts-community-plugins/struts2-jquery/issues/20 :( – Alireza Fattahi Jan 19 '15 at 08:13
-
It is not clear for me in which way (with which options) jqGrid are used by struts2. I asked user2656883 to clear it. In case of loading the data from the server with `loadonce` one can just use old jqGrid with the same good performance. In case of loading the data from `data` option I showed small trick in my answer (setting `data` inside of `onInitGrid`) which works with jqGrid 4.6.0. I suppose that the user didn't included `gridview: true` option. If he did it then even loading of 1000 rows (with small number of columns) will be very quickly. – Oleg Jan 19 '15 at 09:57
-
If you would try to use `loadonce: true` with 1000 rows you will see that loading of initial data works typically very quickly. The local paging 20 by 20 rows will be works practically immediately in jqGrid. Every round trip to the server is many times slower as local paging. You can try this and you will be surprised about the performance. Don't forget about `gridview: true` option. – Oleg Jan 19 '15 at 10:01
-
1The page size of 1000 rows is too high, even if 100 rows are displayed in the grid it would scroll down up to 10 times to get the last row before you move to the next page. Also pagination logic is implemented in the action that is using projection inside the data available in the database to retrieve necessary amount of data to display by the grid. – Roman C Jan 19 '15 at 10:59
-
@RomanC: I suggested to use the same 20 rows for the page, but to use **local paging**. You should just try to return from the server all 1000 rows and to use `loadonce: true`. I write about it because some years before I implemented very good and optimal (from C# and the database point of view) implementation which used 300-1200 rows of data with **server side paging**. After that I tried `loadonce: true` and was wander about the performance. I had to change the implementation and to remove nice code which I wrote before. Try [here](http://www.ok-soft-gmbh.com/jqGrid/performane-90000__.htm)! – Oleg Jan 19 '15 at 11:48
-
I think it would be optimal solution to page data locally and load it on demand. Of course if you preload data that will be available for paging with that option you can improve performance on client but the page load is degradating significantly if the amount of data needed to load and/or store locally is too high. Recently I have noticed that browsers are simply hang up coming to the modern sites imitating 100% HDD usage. – Roman C Jan 19 '15 at 12:07