PDA

View Full Version : how to sort the local data store programmatically?



mrprabu
16 Apr 2014, 6:37 PM
Hi

How to sort the store programmatically?

in multiselect if boundlist got refresh I have to sort the local store(boundlist store)

Zinnia
16 Apr 2014, 11:01 PM
Use the below code , hope this may help you
list.getStore().sort([ {
property : 'name',
direction: 'ASC'
}
]);

mrprabu
21 Apr 2014, 10:15 PM
HI Zinna,

the above solution is for single field sort. how to sort by multiple fields(columns in model).

Regards,
Prabu

jsakalos
22 Apr 2014, 12:23 AM
Just pass more array elements with sorters to the function such as:



[
{property:'name', direction:'ASC'}
,{property:'price', direction:'DESC'}
]

mrprabu
22 Apr 2014, 12:24 AM
hi

thanks for reply, I tried this but not getting sort.
me.fromField.boundList.getStore().sort([{property:'name', direction:'ASC'}
,{property:'price', direction:'DESC'}]);

jsakalos
22 Apr 2014, 12:34 AM
There must be problem elsewhere.

Try to navigate to http://extjs.eu/apps/saki-gms/ and then type in the console:


Ext.ComponentQuery.query('grid')[0].getStore().sort([{property:'countryCode', direction:'DESC'},{property:'name', direction:'ASC'}])

Now you have sorted descending by country code and then ascending by city.