Thanks for the reply Abdul,

 

I’ve been unable to find an answer to my question in the archives though. I can get the sorting working perfectly if I explicitly set the object I want to sort on (as is done in all the examples I could find), however the name of the column to be sorted needs to passed to the class ideally.

 

In Mike Chambers version for example he uses: return toggle * compareDates(item1.date,item2.date);

 

Now that’s fine when you know that you want to sort on .date but what happens when the dataprovider has different columns to sort on?

 

In my app I have maybe 50 datagrids most of which have a date of some sort. Whether it be startDate, endDate, bookingDate etc.

 

Ideally I want to call return toggle * compareDates(item1[field],item2[field]);  where field is a private variable inside the class telling the sort function the name of the column to sort on. However due to the way the function is passed I can’t think of any way to let that function access a variable.

 

Cheers,

 

Steve

 

 

-----Original Message-----
From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Abdul Qabiz
Sent:
25 August 2005 18:14
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders] Custom Datagrid Sorting

 

Hi Steve,

 

Similar question has been replied in past, I have replied once myself. Please check the flexcoders archive at

 

 http://www.mail-archive.com/flexcoders%40yahoogroups.com

 

if you don't find the answer, please reply in this thread.

 

 

Thanks

 

-abdul

 


From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Steve Cox
Sent: Thursday, August 25, 2005 10:18 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Custom Datagrid Sorting

Hey guys,

 

Right, I’ve a situation where I need to sort a particular datagrid column as a date, however the value of the cell is actually a string (eg 7th Aug 2005).

I’ve got this all working, however I’m trying to package it up as a class so I can reuse it 100 times through the various datagrids I’ve got. My problem is I’m calling:

 

dg.dataProvider.sortItems(dateFieldCompare, ((sortOrder == 1)? 0: Array.DESCENDING));

 

Where dg is my datagrid (passed through via the class constructor). The issue I’m having is that I cannot access any variables from the dateFieldCompare function. My constructor header is as follows:

 

public function DateSortUtil(myDg:mx.controls.DataGrid,columnIndex:Number,field:String) {

 

Ideally I want field to be accessible to the dateFieldCompare function so I know what field to compare. The following is the header from dateFieldCompare:

 

private function dateFieldCompare(item1:Object, item2:Object, bit:Number):Number

 

To get it working at the moment I’m having to compare item1.date and item2.date . However ‘date’ won’t always be the name of the fields I want to compare, and item1[field] isn’t going to work.

 

Any ideas?

 

Cheers, Steve




--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com




SPONSORED LINKS
Computer software testing Macromedia flex Development
Software developer


YAHOO! GROUPS LINKS




Reply via email to