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
Custom sort function on column
21/10/2009
05:36
Avatar
lotjuh
Member
Members
Forum Posts: 28
Member Since:
06/09/2009
sp_UserOfflineSmall Offline

Hi everyone,

I've been searching for a while, but I can't find anything about how to add a custom sort function to a column. I'm not even sure if it's possible in jqgrid.

As you can see at http://www.gebroederslaan.nl/b.....chema.html I have cells that just show a color. I've accomplished this by using a custom formatter for these columns:

 function colorFormatter(cellvalue, options, rowObject) {
     if(cellvalue == 1) {
         return '<div class=”ui-state-highlight”>&nbsp;</div>';
     }
     else {
         return '';
     }
 }

But now I want to be able to sort on these columns as well. Since there's no real value in it, jqgrid won't sort it. So I want to use a custom sort function which checks if there's an html element with the class “ui-state-highlight” in it or not to handle the sorts.

Does anyone know how to do this?

Kind regards Lotte-Sara Laan

21/10/2009
14:17
Avatar
dsh0105
Member
Members
Forum Posts: 4
Member Since:
26/08/2009
sp_UserOfflineSmall Offline

I don't have an exact answer for you.. but I can suggest a quick work around: use your custom formater to font-color of the value to the same as the background then let the normal column sort do it's magic.  I'm sure someone with more JQgrid experince can offer a JQgrid solution though.

21/10/2009
15:56
Avatar
lotjuh
Member
Members
Forum Posts: 28
Member Since:
06/09/2009
sp_UserOfflineSmall Offline

Yeah I thought about that solution myself as well, but I found it rather ugly since the user can see the '0' and '1' as soon as they do a text select on the cell.

And I do have other places where I'd like to use a custom sort function like columns with ip addresses I use in a different project.

Forum Timezone: Europe/Sofia

Most Users Ever Online: 994

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