2011-02-01 149 views
0

嗨我在日期有問題。Adob​​e Flex日期

我有一個自定義dateChooser。

在dateChooser組件中,突出顯示了一些假期,並同時在容器中列出了假期。

問題是我在容器中顯示的日期沒有按升序排列,有些人請幫忙。

鏈路用於與視圖源演示應用程序啓用

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

的所述邏輯是在custome文件夾下ExtendedDateChooser.as實現。

+0

我看不到您的演示應用程序中提到的容器。我們如何看到你的排序不能正常工作的例子? – 2011-02-01 16:14:24

+0

您好,請滾動瀏覽日期選擇控件。你會看到容器,因爲沒有假期2月容器沒有顯示。 – Arulmurugan 2011-02-01 18:02:39

回答

0

我想,你不能按日期排序。

首先,我在您的應用程序中看不到容器。

我的方法是解析日期以毫秒爲單位自1970年以來

parse(date:String):Number 

然後,你可以通過一些邏輯排序。

BR 弗蘭克

+0

您好請滾動瀏覽日期選擇器控制大。你會看到容器,因爲沒有假期2月容器沒有顯示。 – Arulmurugan 2011-02-01 17:40:02

1

你們是不是要進行排序在 'holidayView' VBOX的日期? 你不能比較和排序兩個日期。您可以使用下面給出的日期比較方法(在網上搜索找到一個更好的)。如果在VBOX顯示假期的控制是一個DataGrid,在標籤屬性使用

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

將導致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)); 
     }