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
sort by multiple columns
13/12/2008
20:27
Avatar
mbasil
New Member
Members
Forum Posts: 1
Member Since:
14/12/2008
sp_UserOfflineSmall Offline

I'm just starting out with jquery.  I really like what I see with jqgrid.   One thing I haven't seen is a way to sort by multiple columns at once.

Am I missing something in the doc, is there a workaround, or is this a feature that is on the horizon?

mb

16/12/2008
03:01
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello,

You can do that.

1. You can define in the index multiple names something like

index: " name1 name2" - this string will be send to the server and you

can get it and sort appropriate way.

2. Use onSortCol to do that - also you can check example how

we can sort on hidden fields - the things are the same.

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.

13/05/2009
02:51
Avatar
Clement
Member
Members
Forum Posts: 48
Member Since:
30/03/2009
sp_UserOfflineSmall Offline

Hi Tony,

How can we do multi column sort by simply clicking on the column titles? Can we make the sort direction arrow appear for all the sorted columns?

Thanks!

13/05/2009
13:33
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello,

For the first you can use the hints in this topic.

For the second my ansver is: currently  not possible.

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.

15/05/2009
04:05
Avatar
Clement
Member
Members
Forum Posts: 48
Member Since:
30/03/2009
sp_UserOfflineSmall Offline

Hi Tony,

I do not quite understand what you mean. Could you elaborate or provide examples or links to examples?

Thanks!

20/05/2009
10:02
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello,

To be a clear. When you click on one column you can simulate a sort on multiple coulmns sending the appropriate data to the server, but we can not sumulate this beghaviour (or at leaset is difficult) - click and some column (the data is sorted and sorting image appear), click on other column the sort of the first should remain again with the image, but again sorted to the second with the image and etc.

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.

20/05/2009
20:56
Avatar
Clement
Member
Members
Forum Posts: 48
Member Since:
30/03/2009
sp_UserOfflineSmall Offline

Hi Tony,

Do you mean adding two onSortCol events (one desc and the other asc) for each column and each click to update the sortname and sortorder via setGridParam?

For example, initial sort is "Col_1 asc"

Then clicking on Col_2 would set sortname to "Col_1 asc, Col_2" and sortorder to "asc". Next click on Col_3 would set sortname to "Col_1 asc, Col_2 asc, Col_3" and sortorder to "asc". I think you have something else in mind.

My approach above seems to create a mess if I click on the same column more than once. A search and replace function would need to be in place to manipulate the sortname string and retain the order of last clicked column in sortorder. I would also need a sort reset button. Not elegant at all..

Please advise further.. Thanks!

25/05/2009
03:25
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello Clement,

I'm not sure that what you want can be done with jqGrid.

I mean the following.

When you click on one column to sort you can add many columns to the request, but nothing more

something like

onSortCol :  function(index, iCol, sortorder) {

if(index=='some') {

$("#mygrid").setGridParam({sortname: "col1 col2 col3..',sortorder:'asc or desc'});

}

if(index=='other') {

$("#mygrid").setGridParam({sortname: "col3 col2 col1..',sortorder:'asc or desc'});

}

}

Do you see what I mean, but nothing more

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.

30/05/2009
01:51
Avatar
Clement
Member
Members
Forum Posts: 48
Member Since:
30/03/2009
sp_UserOfflineSmall Offline

Hi tony,

That's part of my requirements.. I also need subsequent clicks on same column header to reverse the sort direction or remove sorting on that column.

For example, we have columns A, B and C.

First click on column A -> sort parameter: A asc

Then click on B -> sort parameter: A asc, B asc

Then click on C twice -> sort parameter: A asc, B asc, C desc

Then click on B -> sort parameter: A asc, B desc, C desc

Then click on B again -> sort parameter: A asc, C desc (Sort on B is off)

Thanks!

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

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