Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

extjs - Sort store alphanumerically and case insensitively

Tags:

store

extjs

I want to sort store (ArrayStore and GroupingStore) alphanumerically and case INSENSITIVELY. I am using singleSort() method but it sorts case sensitively.

For example,

data = ['c', '1', 'A', 'a', 'C']
output = ['1', 'A', 'C', 'a', 'c']
myoutput = ['1', 'a', 'A', 'c', 'C'] or [['1', 'A', 'a', 'C', 'c']    // This is what I want

Any suggestion on how to achieve this?

like image 452
user427969 Avatar asked Mar 29 '11 22:03

user427969


1 Answers

I found a much simpler way

using ExtJS 3.3.1, probably works with earlier too.

Simply define the sortType for the field as asUCString, like this:

new Ext.data.JsonStore({ 
   url: 'my.php', 
   fields: [{name:'name', sortType:Ext.data.SortTypes.asUCString}], 
   sortInfo: { field: 'name', direction: 'ASC'} 
});
like image 137
Duncan Avatar answered Oct 05 '22 07:10

Duncan