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_Related Related Topics sp_TopicIcon
Case, accent and punctuation insensitive sorting
Tags: Sorting
11/04/2011
21:43
Avatar
McCulloch
Toronto, ON, CA
Member
Members
Forum Posts: 6
Member Since:
11/01/2011
sp_UserOfflineSmall Offline

Currently the sorttype property of a column defines the type of the column for appropriate sorting.

Possible values include int/integer – for sorting integer ; float/number/currency – for sorting decimal numbers ; date – for sorting date and text – for text sorting.

I have a need for case, punctuation and accent insensitive text sorting. Does anyone know how to use a custom sorting fuction to achieve this?

For example, currently jqGrid sorts a column in this order:

  1. Cross-border reorganization
  2. Crystallization of…
  3. Crédit d'impôt …
  4. Draft Guidance on …
  5. Dubai Investment
  6. Décisions récentes
  7. Lutte contre les planifications fiscale
  8. L’Institut des Cadres Fiscaliste: …
  9. Majoration fiscale …
  10. World Tour …
  11. École de hautes …

The requirement is to have a sortable column in this order:

  1. Crédit d'impôt …
  2. Cross-border reorganization
  3. Crystallization of…
  4. Décisions récentes
  5. Draft Guidance on …
  6. Dubai Investment
  7. École de hautes …
  8. L’Institut des Cadres Fiscaliste: …
  9. Lutte contre les planifications fiscale
  10. Majoration fiscale …
  11. World Tour …
11/04/2011
23:25
Avatar
McCulloch
Toronto, ON, CA
Member
Members
Forum Posts: 6
Member Since:
11/01/2011
sp_UserOfflineSmall Offline

Here is what I ended up doing:

$("#dataGrid").jqGrid({
    ...
    colModel: [

        { name: 'subject', index: 'subject', sortable: true, classes: 'ui-ellipsis', width: columnWidths.subject,
            sorttype: function (cell) { return sortable(cell); } }
        ],
    ...               

});

...

function makeSortable(s)
{
    var r = s.toLowerCase();
    var diacritics = [
        [/[\340-\346]/g, 'a'],
        [/[\350-\353]/g, 'e'],
        [/[\354-\357]/g, 'i'],
        [/[\362-\370]/g, 'o'],
        [/[\371-\374]/g, 'u'],
        [/[\361]/g, 'n'],
        [/[\347]/g, 'c']
    ];

    for (var i = 0; i < diacritics.length; i++)
    {
        r = r.replace(diacritics[i][0], diacritics[i][1]);
    }
    return r;
}

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

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