View Full Version : Is sortType supported in new grid?

23 Feb 2007, 6:31 AM

I'm playing with new grid and I have a question. In 0.33 ColumnModel has a 'sortType' parameter, so one can do some changes to column data for sorting.

But in 1.0 sortType didn't work. I read forum topics, looked at examples, but failed to understand how to do "advanced" sorts in new Ext.

23 Feb 2007, 7:04 AM
The sort types in the new grid are much easier to use and most of the time aren't needed.

For example, when you define a field as type "int", any incoming data (i.e. XML String) are automatically converted to int, data is automatically sorted as an int, etc.

The same applies for type: 'string', 'date', 'float'. For strings, they are automatically sorted case insensitive (unlike old version).

However, if you require a custom sort type there are options for that as well. You can reference one of the predefined sort types by name (see SortTypes.js):

sortType: 'asText'

and you can also pass in a function (including a custom function):

sortType: Ext.data.SortTypes.asText

The type and sortType options are on a field in the record definition.

23 Feb 2007, 7:44 AM
Thanks for the answer, Jack! Adding sortType to the record definition works fine.

I really need to use custom sort function in my app, cause data I have to display is quite complex.

2 May 2007, 5:21 PM
Referencing sorting function by name doesn't help in my case (ext 1.0). A column with integer values is still sorted as text.

{id: "s_6", header: "State" ,width: 64,dataIndex: 's_6' ,type: 'int', sortType:'asInt'}

The function ds.fields.get('s_8').sortType -- comes back as function (s) { return s; }

Is there a trick to make this work?