Arulmurugan
Arulmurugan

Reputation: 107

Adobe Flex date

Hi I am having a problem in date.

I am having a custom dateChooser.

In the dateChooser component highlights some holidays and at the same time lists the holidays in a container.

The Problem is the date I am displaying in the container is not in ascending order could some one please help.

Link for the demo application with view source enabled

http://125.22.254.206/clients/flexdemos/calendardemo/calendardemo.html

The said logic is implemented in ExtendedDateChooser.as under custome folder.

Upvotes: 0

Views: 319

Answers (2)

kbgn
kbgn

Reputation: 856

Are you trying to sort the date in the 'holidayView' vbox? You cant compare and sort two dates. You can use the date comparison method given below (search the web to find a better one).If the control in the vbox to display holidays is a datagrid, using

<mx:DataGridColumn
      headerText="Created Date"
      date="createdDt"
      sortCompareFunction="date_sortCompareFunc">
</mx:DataGridColumn>

in the tag attribute will result in sortedDate

private function date_sortCompareFunc(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=isoToDate(itemA.createdDt);
           var dateB:Date=isoToDate(itemB.createdDt);
           return ObjectUtil.dateCompare(dateB, dateA);
       }

 private function isoToDate(value:String):Date {
            var dateStr:String = value;
            dateStr = dateStr.replace(/\-/g, "/");
            dateStr = dateStr.replace("T", " ");
            dateStr = dateStr.replace("Z", " GMT-0000");
            return new Date(Date.parse(dateStr));
        }

Upvotes: 1

Frank
Frank

Reputation: 800

I think, you cant sort by Date.

First, I can't see the container in your app.

My way would be to parse the date in to milliseconds since 1970

parse(date:String):Number

Then you can sort it by some logic.

BR Frank

Upvotes: 0

Related Questions