View Full Version : Programmatically resort Grid columns?

30 Aug 2011, 8:05 AM
I need to programmatically resort Grid columns (i.e. simulating a mouse click in the grid header). While I understand I could actually just simulate a DOM mouse click, I'd rather instruct the Grid via a method call, etc. After spending the morning with the docs, I don't see anything that seems to work - the closest I've found is in Ext.grid.header.Container's headerclick (http://docs.sencha.com/ext-js/4-0/#!/api/Ext.grid.header.Container-event-headerclick) event. Am I on the right track?

30 Aug 2011, 1:11 PM
Ok, managed to do it with via the Store's sort method. Basically, resort the Store data, and the view automatically updates. Very cool...
var s = Ext.data.StoreManager.lookup('EpisodeSummaryJsonStore');
s.sort('episode') // sort on 'episode' column. Sort order is maintained internally to the Store, so repeat calls to the sort method will toggle the sort between ASC and DESC!

23 Dec 2013, 3:30 PM
Ext.getStore('MetaChecklistStore').sort({ property: 'sequenceNumber', direction : 'ASC' });