3.2.0

Custom Sorting

I have the following severities that I need to sort in that order but I'm not sure how to accomplish it short of putting a number in front of each so that the sorter sorts the numbers instead of the words. Any ideas?

Global
Urgent
High
Medium
Low
Mike
June 30,
bump
Mike
July 5,
v.2.0.1 btw
Mike
July 6,
u can make an CellFormat for u, and then implement compareTo function.
Paulo Cesar Silva Reis (PC from Brazil).
July 6,
This isn't exactly what you are asking for, but it might work for you. You need to actually populate the grid with numbers. The trick is to sort the numbers and to return appropriate text for those numbers when displaying. Also, for some reason, in my example, the numbers that you want to sort need to be in quotes (unless all of the values are unique, which they probably won't be). I just posted a bug related to that.

var obj = new AW.UI.Grid;
var data = [
[1,"1"],
[2,"1"],
[3,"2"],
[3,"2"],
[3,"3"],
[3,"3"],
[3,"4"],
[3,"4"],
[3,"5"],
[3,"5"]
];
obj.setCellData(data);
obj.setCellText(function(c,r){var v=obj.getCellData(c,r);
if(v==1)return'Global';
if(v==2)return'Urgent';
if(v==3)return'High';
if(v==4)return'Medium';
if(v==5)return'Low';
},1);
obj.setRowCount(10);
obj.setColumnCount(3);
document.write(obj);
DT
July 7,
That'll do it, thanks!
Mike
July 7,
Or, you can put text labels into cell/text and put the function into cell/value which translates them to sortable values (numbers). Grid uses cell/value property for sorting.
Alex (ActiveWidgets)
July 9,

This topic is archived.

See also:


Back to support forum