Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted on Apr 27, 2008 14:42
open dhtmlx forum
Dhtmlx grid Sort

Iam using the F-12 key to add a new row to the grid. I would like to sort the grid on the date column whenever a new row is added. How can this be done?
Answer posted by support on Apr 28, 2008 02:27
mygrid.attachEvent("onRowAdded",function(){
    mygrid.sortRows(INDEX)
    return true;
})

where INDEX - index of column in question
Answer posted on Apr 28, 2008 11:11
I actually want to sort the grid based on the submission date and submission time and these are two columns in the grid. Can this be done? 
Answer posted by Support on Apr 29, 2008 03:02
You can use complex custom sorting function or just the next approach

mygrid.attachEvent("onRowAdded",function(){
    mygrid.enableStableSorting(true);
    mygrid.sortRows(INDEX_time,"str","asc");   // sort by lesser value
    mygrid.sortRows(INDEX_date,"str","asc");   // sort by higher value
    return true;
})

Attachments (1)