Forum

July 12th, 2025
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
Sorting with Paging
21/10/2009
13:32
Avatar
josh
Member
Members
Forum Posts: 5
Member Since:
21/10/2009
sp_UserOfflineSmall Offline

With paging enabled, if I jump to page 3 and then change the sort order by clicking a column, the sorting changes and I am sent back to page 1.  Is there a way to retain the page that I am on when the sort order changes?  In other words, when I am on page 3 and I change the sort order, I'd like to stay on page 3.

Thanks.

23/10/2009
11:42
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello,

Look at onSortCol event. It will do the job.

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.

26/10/2009
10:36
Avatar
josh
Member
Members
Forum Posts: 5
Member Since:
21/10/2009
sp_UserOfflineSmall Offline

OK - I can set the page within onSortCol and the list jumps to that page after sorting:

onSortCol: function(index,iCol,sort){jQuery("#list").setGridParam({page:3});

However, I obviously don't want to hard-code the page number... and instead it should be set depending on what page I'm on when I click the column to sort by.   How can I fetch the current page in order to set it in the setGridParam above?  When I call $('#list').getGridParam('page') from within the onSortCol function, it returns "1" even if I'm on page 5.

26/10/2009
11:11
Avatar
Rumen[Trirand]
Moderator
Members

Moderators
Forum Posts: 81
Member Since:
08/10/2009
sp_UserOfflineSmall Offline

Yes, the page the grid is currently on is accessible in the property (option, in jQuery UI terms) "page". To access it, use something like that

var grid = $("#myGridID");

var page = grid.getGridParam('page')

then pass the page variable on with the sort events.

Trirand ASP.NET WebForms & MVC components based on jQuery & ThemeRoller

http://www.trirand.net

26/10/2009
13:11
Avatar
josh
Member
Members
Forum Posts: 5
Member Since:
21/10/2009
sp_UserOfflineSmall Offline

Right... I had tried that.  See my last post:

"When I call $('#list').getGridParam('page') from within the onSortCol function, it returns “1″ even if I'm on page 5."

I tested this by simply placing an alert($('#list').getGridParam('page')) inside the onSortCol function.  If I'm on, for example, page 5 and click a column to change the sort, the alert box displays "1", instead of "5" like I would have thought.  Any idea why or what I could try different?

26/10/2009
13:16
Avatar
josh
Member
Members
Forum Posts: 5
Member Since:
21/10/2009
sp_UserOfflineSmall Offline

I suppose that I could keep track of the page number by creating a variable for currentPage and then doing something like:

onPaging: function() { currentPage = $('#list').getGridParam('page'); },

onSortCol: function() { jQuery('#list').setGridParam({page:currentPage});

But is there a cleaner way??

27/10/2009
03:58
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello,

The solution is a little bit tricky.

onSortCol: function(index,iCol,sort){

var postpage = jQuery(”#list”).getGridParam('postData');

jQuery(”#list”).setGridParam({page:postpage.page});

}

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.

27/10/2009
12:17
Avatar
josh
Member
Members
Forum Posts: 5
Member Since:
21/10/2009
sp_UserOfflineSmall Offline

Perfect.  Thank you.

28/10/2009
09:21
Avatar
pupian
Guest
Guests

yeah it stayed at the current page but the data.. but it sorts all the data not the data within the selected page. is there any way to sort the data in the selected page?

for instance i have an alphabet table:

im in page 2 and the data in the table are-

p

s

t

r

and i want to sort those data and it would be like:

p

r

s

t

not like:

a

b

c

d

or

w

x

y

z

Forum Timezone: Europe/Sofia

Most Users Ever Online: 994

Currently Online:
20 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