9/15/2010 10:55:38 PM
Title:
datagrid sorting
hi to all. i have one datagrid and i created the column of datdgrid dynamically , my grid having lot of columns. in that i want to sort my grid date combine of 2 column.for example i want to sort my data with combine of date and time.can i do it in flex. plz help me. i want to do it in datagrid not in advance datagrid..
9/16/2010 10:36:06 AM
you should check this link it shows multiple column sorting in datagrid and advanceddatagrid
http://raghuonflex.wordpress.com/2008/01/25/programmatic-multi-column-sorting-on-datagrid-or-advanceddatagrid/
12/3/2010 3:00:50 AM
var col:DatagridColumn = new DataGridColumn();
col.dataField = "name";
col.sortCompareFunction = caseInsensitiveDateSortFunction(col.dataField);
// Date and Time Compare Function
private function caseInsensitiveDateSortFunction(field:Object):Function {
return function(itemA:Object, itemB:Object):int
{
/* Date.parse() returns an int, but
ObjectUtil.dateCompare() expects two
Date objects, so convert String to
int to Date. */
var dateA:Date;
if(itemA[field]!=""){
//Alert.show("IN IF AA");
dateA = new Date(Date.parse(itemA[field]));
}
else{
//Alert.show("IN ELSE");
dateA = new Date(0000,00,00);
}
var dateB:Date;
if(itemB[field]!=""){
//Alert.show("IN IF AA");
dateB = new Date(Date.parse(itemB[field]));
}
else{
//Alert.show("IN ELSE");
dateB = new Date(0000,00,00);
}
//Alert.show(dateA.toDateString() + " DATEA "+dateB.toDateString()+" DATEB");
return ObjectUtil.dateCompare(dateA, dateB);
};
}
Regards,
Nilesh