user3546785
user3546785

Reputation: 177

Extjs: How to set a grid column header to be the default sort column

I am using Extjs 4.2. I am doing a search and get all the search results to a grid. Whenever I do a search, I want one particular column to be my default sort column with the values getting sorted in ascending order. Once I get the search results, I may select a different column header and do a sort on that particular column. And when I reset the page or do the search once again, I want the default column header to be highlighted and the values sorted based on that column values. Right now , if I click on a column header and do a search again, the same column header is getting highlighted in the new search results.

For example, say I have 3 columns in my grid. FirstName, LastName and Entered Date. I want the Entered Date column to be my default sort column header everytime the page loads or the grid loads or after every search. Even though I select the FirstName header and do a sort on that column manually, if I do a search again, I want the Entered Date column header to be highlighted and sorted. Can anyone give me an idea of how this can be done?.

Upvotes: 0

Views: 7188

Answers (2)

Tarabass
Tarabass

Reputation: 3152

Or order/filter dynamically:

store.sort('height', 'ASC');

or

store.sorters.add(new Ext.util.Sorter({property : 'shoeSize', direction: 'ASC' }));
store.sort();

Upvotes: 3

Medley
Medley

Reputation: 11

You should add the property sorters in the store.

For example, if you want to sort on the column "enteredDate" :

Ext.define("MyApp.store.MyStore", extend : "Ext.data.Store", model : "", sorters : "enteredDate", ....);

Upvotes: 0

Related Questions