Forum



21:43

11/01/2011

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:
- …
- Cross-border reorganization
- Crystallization of…
- Crédit d'impôt …
- …
- Draft Guidance on …
- Dubai Investment
- Décisions récentes
- …
- Lutte contre les planifications fiscale
- L’Institut des Cadres Fiscaliste: …
- Majoration fiscale …
- …
- World Tour …
- École de hautes …
- …
The requirement is to have a sortable column in this order:
- …
- Crédit d'impôt …
- …
- Cross-border reorganization
- Crystallization of…
- …
- Décisions récentes
- …
- Draft Guidance on …
- Dubai Investment
- …
- École de hautes …
- …
- L’Institut des Cadres Fiscaliste: …
- …
- Lutte contre les planifications fiscale
- Majoration fiscale …
- …
- World Tour …
- …
23:25

11/01/2011

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;
}
Most Users Ever Online: 715
Currently Online:
66 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.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66