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
Printable View
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:
Cheers,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);
John