0

I am trying to sort my results grid based on a default column header every time the results gets displayed. I tried giving a sorter to the store and it worked fine when the page loads first time. Its working as I want it to be. But the problem arises only when I try to click on a different column header in the grid. When I click on a different header it sorts based on that particular column values. If I click on search button at this point of time without reloading the page, the search results get displayed and are sorted based on my previous selected column. I want this to be sorted based on the default column. Problem is the grid gets refreshed with search results every time I click on search or reset buttons but the column headers are not getting refreshed. So the results are getting sorted based on my previous selection. To fix this problem, I am trying to reload the whole page every time I click on search or reset. Is there a way that I can refresh the column headers along with the search results every time I click on the search so that the results get sorted based on the default column header. I am able to refresh the search results and the pagination part for every search but not the column headers. Any solution...

Thanks....

user3546785
  • 157
  • 1
  • 7
  • 16

2 Answers2

2

One thing you didn't mention is whether you really want to allow the user to sort by different columns.

You can switch this behaviour off in the columns definition using sortable: false http://docs.sencha.com/extjs/4.2.2/#!/api/Ext.grid.column.Column-cfg-sortable

If you want to keep that behaviour, you can replace the sorters with the default one again on every load:

var myDefaultSorter=Ext.create('Ext.util.Sorter',{
    property:"MyProperty",
    direction:"ASC"
});

store.on('beforeload',function(store) {
    store.sorters.clear();
    store.sorters.add(myDefaultSorter);
}
Alexander
  • 19,906
  • 19
  • 75
  • 162
0

Have you tried store.sorters.clear() ?

Tyr
  • 2,810
  • 1
  • 12
  • 21