Forum


05:56

Hello,
I recently updated from jqgrid 3.4 to 3.5.2, and now the code I put in the loadComplete doesn't seem to work anymore. The code is the following:
loadComplete : function(){
var pageSize = $('#grid').getGridParam("rowNum");
var totalRecords = $('#grid').getGridParam('records');
var totalPages = Math.ceil(totalRecords/pageSize);
var currentPage = $('#grid').getGridParam('page');
if(currentPage> totalPages && totalPages!=0){
$('#grid').setGridParam({page:totalPages}).trigger('reloadGrid');
}
}
I wrote this function as a fix for the following problem: say your pageSize is set to 10, and you've got 27 pages with each 10 records. When you navigate to the last page, that is 27/27 and then change the pageSize to, let's say 30, you end up with 9 pages, but the current page is still 27/9, which is not correct. The loadComplete method stated above fixed this problem in 3.4, but it doesn't work in 3.5.2, it just doesn't reload my grid to the right page! Does anybody have an idea why?
Thanks in advance!
05:59

Moderators
30/10/2007

Hello,
The problem is fixed. Please download the latest version from GitHub.
Regardas
Tony
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
06:03

Thank you for the quick reply!
I would download the latest version, but I can only use version 3.5.2 because I use a new web application framework which comes packaged with jqgrid 3.5.2. So normally I'd have to wait until the framework uses another version of jqgrid, but I think that could take a while. I suppose there is no other "quick fix" I could use until the framework is updated?
09:11

Hello,
I noticed that this bug still happens when you dynamically change the url of the jqgrid.
EDIT: I use jqgrid 3.5.3
I have a button below my jqgrid, which changes the url of the grid to only show a part of the data. So, when you're on page 29/29, and you click the button, you end up on page 29/22, which should be 22/22.
I tried to fix this problem by using the code I posted as a start of this topic, but it doesn't work.
10:26

Moderators
30/10/2007

Hello,
Could you please post the code when you click the button to change the url
Thanks
Best Regards
Tony
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
01:35

Hello Tony,
Here is my code that gets executed when the button is clicked:
$('#grid').trigger("reloadGrid");
This way I filter the grid on the 'active' records.
10:27

Moderators
30/10/2007

Hello,
I think that the problem is in the response from the server. Could you please check this. Every element is recalculated when new request is done.
Regards
Tony
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
03:03

Ah yes, I managed to solve it on server side. I should have thought of this myself.
But it's strange, I thought jqgrid solved this problem by itself, because when you do regular paging and you go from a lower pagesize to a higher pagesize (for example, change pagesize 10 to 30), then jqgrid does solve it by itself: if the current page is greater than the pagesize, the current page gets edited.
Anyway, thanks a lot for your help Tony!
Most Users Ever Online: 715
Currently Online:
57 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
OlegK: 1255
markw65: 179
kobruleht: 144
phicarre: 132
YamilBracho: 124
Renso: 118
Member Stats:
Guest Posters: 447
Members: 11373
Moderators: 2
Admins: 1
Forum Stats:
Groups: 1
Forums: 8
Topics: 10592
Posts: 31289
Newest Members:
, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66