What Is ExtJS ExtJS 4+ Extensions Examples Tutorials

14Jun/123

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.6/10 (12 votes cast)
ExtJS 4.1 Data Store Sorting, 8.6 out of 10 based on 12 ratings
Comments (3) Trackbacks (0)
  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’
    ]

    VA:F [1.9.22_1171]
    Rating: 4.3/5 (6 votes cast)
  2. The best thing is to write:

    sorters: [{
    property: ‘FirstName’,
    direction: ‘ASC’
    }]

    VA:F [1.9.22_1171]
    Rating: 3.6/5 (8 votes cast)

Leave a comment

* Copy This Password *

* Type Or Paste Password Here *

No trackbacks yet.