Flex DateChooser控件

2018-01-01 18:36 更新

介紹

DateChooser控件用于顯示月份的名稱,年份和月份的網(wǎng)格,其中列標(biāo)有星期幾。

DateChooser控件允許用戶選擇日期,日期范圍或多個日期。 該控件包含用于更改月份和年份的前進和后退箭頭按鈕。

類聲明

以下是 mx.controls.DateChooser 類的聲明:

public class DateChooser 
   extends UIComponent 
      implements IFocusManagerComponent, IFontContextComponent

公共財產(chǎn)

S.N.屬性和描述
1

allowDisjointSelection:Boolean

如果為true,則指定在DateChooser控件中允許非連續(xù)(不相交)選擇。

2

allowMultipleSelection:Boolean

如果為true,則指定在DateChooser控件中允許多個選擇。

3

dayNames:Array

DateChooser控件的工作日名稱。

4

disabledDays:Array

在一周內(nèi)禁用的日期。

5

disabledRanges:Array

禁用單天和多天。

6

displayedMonth:int

與displayedYear屬性一起使用,displayedMonth屬性指定在DateChooser控件中顯示的月份。

7

displayedYear:int

與displayedMonth屬性一起使用,displayedYear屬性指定在DateChooser控件中顯示的年份。

8

firstDayOfWeek:Object

表示在DateChooser控件的第一列中顯示的星期幾的數(shù)字。

9

maxYear:int

最后一年可在控件中選擇。

10

minYear:int

第一年可在控件中選擇。

11

monthNames:Array

顯示在DateChooser控件頂部的月份的名稱。

12

monthSymbol:String

此屬性附加到由monthNames屬性指定的值的末尾,以定義顯示在DateChooser控件頂部的月份的名稱。

13

selectableRange:Object

可選擇日期之間的日期范圍。

14

selectedDate : Date

在DateChooser控件中選擇的日期。

15

selectedRanges:Array

所選日期范圍。

16

showToday:Boolean

如果為true,則指定今天在DateChooser控件中突出顯示。

17

yearNavigationEnabled:Boolean

啟用年度導(dǎo)航。

18

yearSymbol:String

此屬性附加到顯示在DateChooser控件頂部的年份末尾。

受保護的屬性

S.N.屬性和描述
1

calendarLayoutStyleFilters:Object

[只讀]要從DateChooser傳遞到日歷布局的一組樣式。

2

nextMonthStyleFilters:Object

[只讀]要從DateChooser傳遞到下一個月按鈕的一組樣式。

3

nextYearStyleFilters:Object

[只讀]從DateChooser傳遞到下一年按鈕的一組樣式。

4

prevMonthStyleFilters:Object

[只讀]從DateChooser傳遞到上個月按鈕的樣式集。

5

prevYearStyleFilters:Object

[只讀]要從DateChooser傳遞到上一年按鈕的一組樣式。

公共方法

S.N.方法和描述
1

DateChooser()

構(gòu)造函數(shù)。

事件

S.N.事件和描述
1

change

在選擇或更改日期時分派。

2

scroll

由于用戶互動而導(dǎo)致月份更改時分派。

繼承的方法

此類繼承以下類中的方法:

  • mx.core.UIComponent

  • mx.core.FlexSprite

  • flash.display.Sprite

  • flash.display.DisplayObjectContainer

  • flash.display.InteractiveObject

  • flash.display.DisplayObject

  • flash.events.EventDispatcher

  • Object

Flex DateChooser控件示例

讓我們按照以下步驟通過創(chuàng)建測試應(yīng)用程序來檢查Flex應(yīng)用程序中DateChooser控件的使用:

步驟描述
1 Flex - 創(chuàng)建應(yīng)用程序章節(jié)中所述,在包 com.tutorialspoint.client 下創(chuàng)建名為 HelloWorld 的項目。
2修改 HelloWorld.mxml ,如下所述。 保持文件的其余部分不變。
3編譯并運行應(yīng)用程序,以確保業(yè)務(wù)邏輯按照要求工作。

以下是修改后的mxml文件 src / com.tutorialspoint / HelloWorld.mxml 的內(nèi)容。

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
   xmlns:s="library://ns.adobe.com/flex/spark"
   xmlns:mx="library://ns.adobe.com/flex/mx"
   width="100%" height="100%" minWidth="500" minHeight="500"
   applicationComplete="application_applicationCompleteHandler(event)"
   >

   <fx:Style source="/com/tutorialspoint/client/Style.css"/>
   <fx:Script>
      <![CDATA[
            import mx.events.CalendarLayoutChangeEvent;
            import mx.events.FlexEvent;

            [Bindable]
            private var selectedDate:String = "";
			
            protected function dateChooser_changeHandler
            event:CalendarLayoutChangeEvent):void
            {            
               var date:Date = DateChooser(event.target).selectedDate;
               selectedDate = dateFormatter.format(date);
            }
			
            protected function application_applicationCompleteHandler
            (event:FlexEvent):void
            {
               selectedDate = dateFormatter.format(new Date());
            }
      ]]>
   </fx:Script>
   <s:BorderContainer width="550" height="400" id="mainContainer" 
   styleName="container">
      <s:VGroup width="100%" height="100%" gap="50" 
      horizontalAlign="center" verticalAlign="middle">
         <s:Label id="lblHeader" text="Form Controls Demonstration" 
         fontSize="40" color="0x777777" styleName="heading"/>
         <s:Panel id="dateChooserPanel" title="Using DateChooser" width="400" 
         height="300" includeInLayout="true" visible="true">
            <s:layout>
               <s:HorizontalLayout  gap="10" verticalAlign="middle" 
               horizontalAlign="center"/>	
            </s:layout>
            <mx:DateChooser id="dateChooser" yearNavigationEnabled="true"
            change="dateChooser_changeHandler(event)"/>
            <s:Label id="selection" fontWeight="bold" 
            text="Date selected: {selectedDate}"/>
         </s:Panel>			
      </s:VGroup>	 
   </s:BorderContainer>	
</s:Application>

準(zhǔn)備好所有更改后,讓我們以正常模式編譯和運行應(yīng)用程序,就像在 Flex - 創(chuàng)建應(yīng)用程序中一樣 章節(jié)。 如果一切順利,您的應(yīng)用程序,這將產(chǎn)生以下結(jié)果:[在線試用]

Flex DateChooser Control
以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號