GRID : sorting by id

Hellow :slight_smile:



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



Thanks for your answer :slight_smile:

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”);

Hello,

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

Any ideas ?

Thanks :slight_smile:

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