header
ask question
Click here to ask Question Now Its free No registration required. Flash, Flex, Flash Media Server, ActionScript,Adobe Air. Most questions receive a response in an hour.
amutha
Points:400
Posts:0

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..



1
Wilbur
Points: 510
Posts:0
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/

2
NileshPawar
Points: 280
Posts:0
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


Post your Reply
Name  

Email

Type your Reply or Answer

Are you human? What is 0+3 



Members Login

Email  
Password
Forgot Password





This website focus on: Flash | Flex | FMS | RED5 | WOWZA | Flash Media Server | Adobe AIR | ActionScript,Flash Solutions | Flash Question | Flash Answers | Flash Developers | Flash Problem, Flash Help, Flash bugs, Flash workaround | Flash Blog | Flex Question Answers | Flash Forum | Flex Development | Actionscript development | Flash development | Adobe AIR development
Copyright © 2008 AskMeFlash.com. All rights reserved. Privacy Policy | Terms & Conditions