:: Forum >>

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
Friday, June 30, 2006
bump
Mike
Wednesday, July 5, 2006
v.2.0.1 btw
Mike
Thursday, July 6, 2006
u can make an CellFormat for u, and then implement compareTo function.
Paulo Cesar Silva Reis (PC from Brazil).
Thursday, July 6, 2006
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
Friday, July 7, 2006
That'll do it, thanks!
Mike
Friday, July 7, 2006
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)
Sunday, July 9, 2006

This topic is archived.


Back to support forum

Forum search