|
-
Datagrid sort by number
Hi all,
When pressing a header in the datagrid the datagrid is sorted alphabetically.
Is there any way to make it sort numerical instead?
Any thoughts?
//pod
-
Anyone figured this out? That is, how to sort a column of numbers in a datagrid? (v2 Component)
-
Sorry no one replied and i didn't figure it
//pod
-
Alright. Looks like we'll just have to figure it out on our own:
Code:
//custom sorting functions for the ranking column
// replace "ColumnName" with the name of the column you want to sort
// in this case, my column was located at columnIndex 2, adjust to suit your needs
function sortNumericASC(a, b) {
return Number(a.ColumnName) > Number(b.ColumnName);
}
function sortNumericDESC(a, b) {
return Number(a.ColumnName) < Number(b.ColumnName);
}
var headerListener = new Object();
headerListener.headerRelease = function(event){
trace("column header num. "+event.columnIndex+" was pressed");
if (event.columnIndex == 2){
if(sortASC == NULL){
sortASC = true;
}else{
sortASC = !sortASC;
}
if(sortASC){
my_dg.sortItems(sortNumericASC);
}else{
my_dg.sortItems(sortNumericDESC);
}
}
};
my_dg.addEventListener("headerRelease", headerListener);
Cheers,
John
Last edited by jvanv8; 08-16-2004 at 11:39 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|