Resolve sorting order when filtering

Dear Sir or Madam,



in the article dhtmlx.com/docs/products/kb/ … g%20filter

the Support writes the following:



“a) please be sure that sortRows is called before filterBy ( after first filtering, grid will lock original row order and will reuse it for next filtering - it can be resolved if necessary )”



I would like to know, how I can resolve the locked row order for the next filtering, so that the filtering is kept every time, if I filter?



To make it more clear:



I have 4 columns in my grid. The initial sorting is by 2nd and then by 1st column. If I filter just after the init and then go back to all rows, and then change the sorting, for example by 3rd column, I want that after the next filtering it has the last sorting order (3rd column). Actually it always get’s the sorting order, which the first filtering process had locked.





Jay



To restore sorting on the 3rd column after filtering you can use “onFilterEnd” event and getSortingState() method. getSortingState() method returns array, first element is index of sorted column, second - direction of sorting (�asc� or �des�). dhtmlx.com/dhxdocs/doku.php?id=d … rtingstate

mygrid.attachEvent(“onFilterEnd”,function(elements){
var sorting=mygrid.getSortingState();
if (sorting.length){
mygrid.sortRows(sorting[0],sorting_type,sorting[1]);//restore sorting after filtering was finished.
mygrid.setSortImgState(true,sorting[0],sorting[1]);
}
})