PDA

View Full Version : sort store on Id



raj_plays
22 Apr 2010, 10:21 PM
Hi,
How to sort a store on its idProperty.
I can sort the below store on 'name' but not on 'id'



var Record3 = Ext.data.Record.create([
{name: 'name', type: 'string'}
]);

var Grid3DataStore = new Ext.data.Store({

proxy: new Ext.data.HttpProxy({url: 'Service.asmx/getRights', method: 'POST'}),
reader: new Ext.data.XmlReader({
record: 'Table',
totalProperty: 'total',
idProperty: 'id'
},Record3),
sortInfo:{field: 'id', direction: "ASC"}
});

gnadirap
22 Apr 2010, 11:06 PM
how does your ID look like in the XML? is it also called id? or has it another name?

Animal
22 Apr 2010, 11:09 PM
Define a Field called "id", then sort on it!

raj_plays
22 Apr 2010, 11:36 PM
Thank you, Animal
I thought about doing what you proposed but it seemed redundant since id is already declared as the idProperty
and so I posted by problem

raj_plays
22 Apr 2010, 11:38 PM
Thank you for writing in gnadirap,
it is called 'id' in the xml

Animal
23 Apr 2010, 12:06 AM
Thank you, Animal
I thought about doing what you proposed but it seemed redundant since id is already declared as the idProperty
and so I posted by problem

You sort on Fields. So add a Field. That is the answer.

Animal
23 Apr 2010, 12:06 AM
Thank you, Animal
I thought about doing what you proposed but it seemed redundant since id is already declared as the idProperty
and so I posted by problem

You sort on Fields. So add a Field. That is the answer.

Condor
23 Apr 2010, 12:20 AM
In Ext 3.2 you could override createSortFunction to return a sort function for the record id, even if there is no field 'id'.

raj_plays
24 Apr 2010, 2:35 AM
Thank you, Condor
I will upgrade to 3.2