Flex-tree-control
フレックス-ツリーコントロール
前書き
Treeコントロールは、展開可能なツリーとして配置された階層データを表示します。
クラス宣言
以下は mx.controls.Tree クラスの宣言です-
public class Tree
extends List
implements IIMESupport
パブリックプロパティ
Sr.No | Property & Description |
---|---|
1 |
dataDescriptor : mx.controls.treeClasses:ITreeDataDescriptor 現在のITreeDataDescriptorを返します。 |
2 |
dataProvider : Object [override] An object that contains the data to be displayed. |
3 |
dragMoveEnabled : Boolean [override] Indicates that items can be moved instead of just copied from the Tree control as part of a drag-and-drop operation. |
4 |
firstVisibleItem : Object ツリーの一番上の行に現在表示されているアイテム。 |
5 |
hasRoot : Boolean [read-only] Indicates that the current dataProvider has a root item; for example, a single top node in a hierarchical structure. |
6 |
itemIcons : Object アイテムのアイコンを指定するオブジェクト。 |
7 |
maxHorizontalScrollPosition : Number [override] The maximum value for the maxHorizontalScrollPosition property for the Tree control. |
8 |
openItems : Object 開かれた、または開かれたアイテム。 |
9 |
showRoot : Boolean ルートアイテムの可視性を設定します。 |
パブリックメソッド
Sr.No | Method & Description |
---|---|
1 |
Tree() コンストラクタ。 |
2 |
expandChildrenOf(item:Object, open:Boolean):void 指定されたアイテムの下のすべてのツリーアイテムを開閉します。 |
3 |
expandItem(item:Object, open:Boolean, animate:Boolean = false, dispatchEvent:Boolean = false, cause:Event = null):void ブランチアイテムを開閉します。 |
4 |
getParentItem(item:Object):* 子アイテムの既知の親を返します。 |
5 |
isItemOpen(item:Object):Boolean 指定された項目ブランチが開いている(子を表示している)場合、trueを返します。 |
6 |
setItemIcon(item:Object, iconID:Class, iconID2:Class):void アイテムに関連付けられたアイコンを設定します。 |
保護されたメソッド
Sr.No | Method & Description |
---|---|
1 |
dragCompleteHandler(event:DragEvent):void [override] Handles DragEvent.DRAG_COMPLETE events. |
2 |
dragDropHandler(event:DragEvent):void [override] Handles DragEvent.DRAG_DROP events. |
3 |
initListData(item:Object, treeListData:mx.controls.treeClasses:TreeListData):void ツリーアイテムレンダラーで使用されるTreeListDataオブジェクトを初期化します。 |
4 |
makeListData(data:Object, uid:String, rowNum:int):BaseListData [override] Creates a new TreeListData instance and populates the fields based on the input data provider item. |
イベント
Sr.No | Event & Description |
---|---|
1 |
itemClose ブランチが閉じられるか折りたたまれたときに送出されます。 |
2 |
itemOpen ブランチが開かれたとき、または展開されたときに送出されます。 |
3 |
itemOpening ブランチのオープンまたはクローズが開始されると送出されます。 |
継承されるメソッド
このクラスは、次のクラスからメソッドを継承します-
- mx.controls.List
- mx.controls.listClasess.ListBase
- mx.core.ScrollControlBase
- mx.core.UIComponent
- mx.core.FlexSprite
- flash.display.Sprite
- flash.display.DisplayObjectContainer
- flash.display.InteractiveObject
- flash.display.DisplayObject
- flash.events.EventDispatcher
- 対象
フレックスツリーコントロールの例
次の手順に従って、テストアプリケーションを作成して、Flexアプリケーションでのツリーコントロールの使用を確認します。
Step | Description |
---|---|
1 | Create a project with a name HelloWorld under a package com.finddevguides.client as explained in the Flex - Create Application chapter. |
2 | Modify HelloWorld.mxml as explained below. Keep rest of the files unchanged. |
3 | Compile and run the application to make sure business logic is working as per the requirements. |
以下は、変更されたmxmlファイル src/com.finddevguides/HelloWorld.mxml の内容です。
<?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">
<fx:Style source = "/com/finddevguides/client/Style.css"/>
<fx:Script>
<![CDATA[
[Bindable]
public var selectedNode:XML;
//Event handler for the Tree control change event.
public function treeChanged(event:Event):void {
selectedNode = Tree(event.target).selectedItem as XML;
}
]]>
</fx:Script>
<fx:Declarations>
<fx:XMLList id = "treeData">
<node label = "E-Mail Box">
<node label = "Inbox">
<node label = "Client"/>
<node label = "Product"/>
<node label = "Personal"/>
</node>
<node label = "Sent Items">
<node label = "Professional"/>
<node label = "Personal"/>
</node>
<node label = "Deleted Items"/>
<node label = "Spam"/>
</node>
</fx:XMLList>
</fx:Declarations>
<s:BorderContainer width = "630" height = "480" id = "mainContainer"
styleName = "container">
<s:VGroup width = "100%" height = "100%" gap = "50"
horizontalAlign = "center" verticalAlign = "middle">
<s:Label id = "lblHeader" text = "Complex Controls Demonstration"
fontSize = "40" color = "0x777777" styleName = "heading"/>
<s:Panel id = "treePanel" title = "Using Tree"
width = "500" height = "300">
<s:layout>
<s:VerticalLayout gap = "10" verticalAlign = "middle"
horizontalAlign = "center"/>
</s:layout>
<mx:Tree id = "tree" width = "95%" height = "75%"
labelField = "@label" showRoot = "false"
dataProvider = "{treeData}" change = "treeChanged(event)"/>
<s:TextArea height = "20%" width = "95%"
text = "Selected Item: {selectedNode.@label}"/>
</s:Panel>
</s:VGroup>
</s:BorderContainer>
</s:Application>
すべての変更が完了したら、link:/flex/flex_create_application [Flex-アプリケーションの作成]の章で行ったように、アプリケーションを通常モードでコンパイルして実行します。 アプリケーションに問題がなければ、次の結果が生成されます。[link:/flex/samples/ComplexControlsApplicationl#currentlyLoaded = Tree [Try it online]]