Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Seth Jennings on Apr 30, 2008 10:20
open dhtmlx forum
Change default onclick sort order

We are using the professional edition version 1.5 build 80111 and would like to find a way to change the default onclick sort order from Ascending to Descending.
Meaning the first time you click a column header, it sorts the data in Ascending order.
I would like to change the first click to be Descending.
Do you have a built in API to handle this or should a custom sort order be built for this?

Thanks for your help and continue to build excellent products.
Answer posted by Support on May 02, 2008 01:51
Basically it can be done in few different ways

a) you can define custom sorting with revertive order

mygrid.setColSorting("custom");
function custom(a,b,order){
    return (a>b?1:-1)*(order=="asc"?-1:1);
}

b) you can define onbeforesort event handler and change the sorting order from it.

mygrid.attachEvent("onBeforeSorting",function(a,b,c){
    if (c=="asc") {
        this.sortRows(a,b,"des");
        return false;
    }
    return true;
})