ExtJS 4.1 Data Store Sorting

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
}
VN:F [1.9.22_1171]
Rating: 8.4/10 (14 votes cast)