Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_TopicIcon
setGridParam 'page' in loadComplete
06/10/2009
05:56
Avatar
HoSpiTaL_gHoSt
Guest
Guests

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!

06/10/2009
05:59
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

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/10/2009
06:03
Avatar
HoSpiTaL_gHoSt
Guest
Guests

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?

05/11/2009
09:11
Avatar
HoSpiTaL_gHoSt
Guest
Guests

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.

06/11/2009
10:26
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

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.

09/11/2009
01:35
Avatar
HoSpiTaL_gHoSt
Guest
Guests

Hello Tony,

Here is my code that gets executed when the button is clicked:

$('#grid').setGridParam({url:'http://localhost:8888/xxx/abc?.....e'});
$('#grid').trigger("reloadGrid");

This way I filter the grid on the 'active' records.

09/11/2009
10:27
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

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.

10/11/2009
03:03
Avatar
HoSpiTaL_gHoSt
Guest
Guests

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!

Forum Timezone: Europe/Sofia

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.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information