Dojox.grid.datagrid sorting order
I was trying to understand the sorting behavior of the dojox.grid.D开发者_C百科atagrid, particularly wondering about a multi-column grid that if sorted on a column where 2 (or more) rows have identical cell values then what determines the order in which they will appear in the grid?
The datagrid only use the selected column for sorting:
getSortProps: function(){
var c = this.getCell(this.getSortIndex());
if(!c){
if(this.sortFields){
return this.sortFields;
}
return null;
}else{
var desc = c["sortDesc"];
var si = !(this.sortInfo>0);
if(typeof desc == "undefined"){
desc = si;
}else{
desc = si ? !desc : desc;
}
return [{ attribute: c.field, descending: desc }];
}
}
So, when you have two rows with the sam cell value, the time of the row addition will descide the order. (Which row is older, that will be in forward position).
Otherwise, you can redefine the getSortProps method on your object, so you can add secondary sorting option.
精彩评论