Search code examples
dhtmldhtmlx

how to sort DHTMLX grid on without clicking on header


I am using DHTMLX grid on a jsp page. From server side i am loading some data on it. I want data to be in sorted manner once it is loaded on grid. I found there is method "grid.sortRows(col, type, order);" but it works only when you click any header, i want by default data will come in sorted manner.


Solution

  • mygrid.load(YOUR_URL, function() {
        // we are in callback
        mygrid.sortRows(0, "str", "des"); // sorts grid
        mygrid.setSortImgState(true, 0, "des"); // sets icon to sort arrow
    });