ExtJS 4+ data stores allow you to sort data rather easily through either a “sorters” configuration on the store itself, or through the store “sort” method. Only one problem: all sorting is case-sensitive. Here’s a quick example of how you can customize the sorter to be case-insensitive, in a context of a combo box:
{ xtype: 'combo', fieldLabel: 'Supervisor', name: 'manager', queryMode: 'remote', store: Ext.create('Ext.data.Store', { fields: ['displayName', 'distinguishedName'], proxy: Ext.create('T4E.proxy.MSAjaxProxy', { url: '/User/SearchManager', reader: { type: 'json' } }), // eo proxy sorters: [{ property: 'displayName' , transform: function(val) { return val.toLowerCase(); } }] // eo sorters }), // eo store displayField: 'displayName', valueField: 'distinguishedName', forceSelection: true, typeAhead: true, minChars: 1 } |
You can also add a SortType to your field. See the Ext JS docs for more info: http://docs.sencha.com/ext-js/4-1/#!/api/Ext.data.SortTypes. It’s like this:
fields: [{
name: ‘displayName’,
sortType: ‘asUCString’
}, ‘distinguishedName’
]
Ah even better!
The best thing is to write:
sorters: [{
property: ‘FirstName’,
direction: ‘ASC’
}]