PDA

View Full Version : Custom sort in Grid



AndrewK
14 May 2008, 3:55 AM
one column of my grid contains only "First" , "Second", "Last",
I want next order

First
Second
Last

if I use
sortInfo: {field: 'fieldname', direction: 'ASC'}
I have

First
Last
Second

any ideas?

14 May 2008, 4:42 AM
Andrew, the Ext grid or data store does not support multi-level sorting.

AndrewK
14 May 2008, 4:58 AM
there is no need is multi-level sorting
for example grid is next:
+-+-------+
|1|First |
|2|Last |
|3|Second|
+-+-------+

after sort I wnat to see
+-+-------+
|1|First |
|3|Second|
|2|Last |
+-+-------+

that's all

evant
14 May 2008, 5:05 AM
You can specify a custom sorting method: http://extjs.com/deploy/ext-2.1/docs/?class=Ext.data.Record&member=create

Have a look at the sortType option.

YargicX
14 May 2008, 5:11 AM
Are there indexes invisible on grid?(1,2,3) If they are visible i think there's no problem.They are sort when you clicked grid's header?

AndrewK
14 May 2008, 5:23 AM
(1,2,3) - just some data, It will be a user names

evant
14 May 2008, 5:28 AM
In your record declaration:



sortType: function(value)
{
switch (value.toLower())
{
case 'first': return 1;
case 'second': return 2;
default: return 3;
}
}

AndrewK
14 May 2008, 6:20 AM
as I understand it will be a weight of this words, thank you

value.toLowerCase() // <- !!!!