Your SlideShare is downloading. ×
Handling Tree control events Hemakumar.S Open Source Developer
Handling Tree control events  <ul><li>The tags that represent tree nodes in the XML data can have any name. The Tree contr...
Definition <ul><li>A branch node can contain multiple child nodes, and, by default, appears as a folder icon with a disclo...
Handling Tree control events  <ul><li>Typically use events to respond to user interaction with a Tree control. Since the T...
Example <ul><li><?xml version=&quot;1.0&quot;?>  </li></ul><ul><li><!-- dpcontrols/TreeEvents.mxml --> </li></ul><ul><li><...
Cont…. <ul><li><mx:Tree id=&quot;XMLtree1&quot; width=&quot;150&quot; height=&quot;170&quot; labelField=&quot;@label&quot;...
Cont…. <ul><li><node label=&quot;Sent&quot; data=&quot;15&quot;/>  </li></ul><ul><li><node label=&quot;Trash&quot; data=&q...
Screen Shot
Handling tree control events
Upcoming SlideShare
Loading in...5
×

Handling tree control events

891

Published on

Tree Control Events in Flex

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
891
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
5
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "Handling tree control events"

  1. 1. Handling Tree control events Hemakumar.S Open Source Developer
  2. 2. Handling Tree control events <ul><li>The tags that represent tree nodes in the XML data can have any name. The Tree control reads the XML and builds the display hierarchy based on the nested relationship of the nodes. For information on valid XML structure, see Hierarchical data objects. </li></ul><ul><li>Some data providers have a single top level node, called a root node. Other data providers are lists of nodes and do not have a root node. In some cases, you might not want to display the root node as the Tree root. To prevent the tree from displaying the root node, specify the showRoot property to false; doing this does not affect the data provider contents, only the Tree display. You can only specify a false showRoot property for data providers that have roots, that is, XML and Object-based data providers. </li></ul>
  3. 3. Definition <ul><li>A branch node can contain multiple child nodes, and, by default, appears as a folder icon with a disclosure triangle that lets users open and close the folder. Leaf nodes appear by default as file icons and cannot contain child nodes. </li></ul><ul><li>When a Tree control displays a node of a non-XML data provider, by default, it displays the value of the label property of the node as the text label. When you use an E4X XML-based data provider, however, you must specify the label field, even if the label is identified by an attribute named &quot;label&quot;. To specify the label field, use the labelField property; for example, if the label field is the label attribute, specify labelField=&quot;@label&quot;. </li></ul>
  4. 4. Handling Tree control events <ul><li>Typically use events to respond to user interaction with a Tree control. Since the Tree control is derived from the List control, you can use all of the events defined for the List control. The Tree control also dispatches several Event and TreeEvent class events, including Event.change and TreeEvent.itemOpen. The following example defines event handlers for the change and itemOpen events. </li></ul><ul><li>Define event listeners for the change and itemOpen events. The Tree control broadcasts the change event when the user selects a tree item, and broadcasts the itemOpen event when a user opens a branch node. For each event, the event handler displays the label and the data property, if any, in a TextArea control. </li></ul>
  5. 5. Example <ul><li><?xml version=&quot;1.0&quot;?> </li></ul><ul><li><!-- dpcontrols/TreeEvents.mxml --> </li></ul><ul><li><mx:Application xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot;> </li></ul><ul><li><mx:Script> </li></ul><ul><li><![CDATA[ </li></ul><ul><li>import flash.events.*; </li></ul><ul><li>import mx.events.*; </li></ul><ul><li>import mx.controls.*; </li></ul><ul><li>private function changeEvt(event:Event):void </li></ul><ul><li>{ var theData:String = &quot;&quot; if (event.currentTarget.selectedItem.@data) </li></ul><ul><li>{ theData = &quot; Data: &quot; + event.currentTarget.selectedItem.@data; } </li></ul><ul><li>forChange.text = event.currentTarget.selectedItem.@label + theData; } </li></ul><ul><li>private function itemOpenEvt(event:TreeEvent):void </li></ul><ul><li>{ forOpen.text = event.item. @label; } </li></ul><ul><li>]]> </li></ul><ul><li></mx:Script> </li></ul>
  6. 6. Cont…. <ul><li><mx:Tree id=&quot;XMLtree1&quot; width=&quot;150&quot; height=&quot;170&quot; labelField=&quot;@label&quot; </li></ul><ul><li>itemOpen=&quot;itemOpenEvt(event);&quot; change=&quot;changeEvt(event);&quot;> </li></ul><ul><li><mx:XMLListCollection id=&quot;MailBox&quot;> </li></ul><ul><li><mx:XMLList> </li></ul><ul><li><node label=&quot;Mail&quot; data=&quot;100&quot;> </li></ul><ul><li><node label=&quot;Inbox&quot; data=&quot;70&quot;/> </li></ul><ul><li><node label=&quot;Personal Folder&quot; data=&quot;10&quot;> </li></ul><ul><li><node label=&quot;Business&quot; data=&quot;2&quot;/> </li></ul><ul><li><node label=&quot;Demo&quot; data=&quot;3&quot;/> </li></ul><ul><li><node label=&quot;Personal&quot; data=&quot;0&quot; isBranch=&quot;true&quot; /> </li></ul><ul><li><node label=&quot;Saved Mail&quot; data=&quot;5&quot; /> </li></ul><ul><li></node> </li></ul>
  7. 7. Cont…. <ul><li><node label=&quot;Sent&quot; data=&quot;15&quot;/> </li></ul><ul><li><node label=&quot;Trash&quot; data=&quot;5&quot;/> </li></ul><ul><li></node> </li></ul><ul><li></mx:XMLList> </li></ul><ul><li></mx:XMLListCollection> </li></ul><ul><li></mx:Tree> </li></ul><ul><li><mx:Form> </li></ul><ul><li><mx:FormItem label=&quot;Change Event:&quot;> </li></ul><ul><li><mx:Label id=&quot;forChange&quot; width=&quot;150&quot;/> </li></ul><ul><li></mx:FormItem> </li></ul><ul><li><mx:FormItem label=&quot;Open Event:&quot;> </li></ul><ul><li><mx:Label id=&quot;forOpen&quot; width=&quot;150&quot;/> </li></ul><ul><li></mx:FormItem> </li></ul><ul><li></mx:Form> </li></ul><ul><li></mx:Application> </li></ul>
  8. 8. Screen Shot
  9. 9. <ul><li>Thank you… </li></ul>

×