Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by dactar on Feb 19, 2009 02:01
open dhtmlx forum
GRID : sorting by id

Hellow :)

Is there a way to sort a grid by id descending without creating a column with the id inside ?

Thanks for your answer :)
Answer posted by Support on Feb 19, 2009 03:16
Custom sorting routine receives 5 parameters, 4th and 5th are IDs of compared row, so you can use

function custom_sort(a,b,order,ida,idb){
       return (ida>idb?1:-1)*(order=="asc"?1:-1);
}
mygrid.sortRows(0,"custom_sort","desc");
Answer posted by dactar on Feb 19, 2009 10:30
Hello,

I've trid this just after an updateFromXML but it doesn't work (I've no javascript error).

Any ideas ?

Thanks :)
Answer posted by Support on Feb 19, 2009 10:44
a) custom sorting routines fully supporte in pro version only
b) update from XML is async. command - you need to use it as

grid.updateFromXML(url,true,false,function(){
           //will be called after data loading
           mygrid.sortRows(0,"custom_sort","desc");
});


or use onXLE event for the same purpose