![]() |
![]() |
||||||
|
|||||||
| Tags: editor, event, getting, item, other, show, thanitemclick, tree |
![]() |
|
|||
|
I have a Tree Component with a dynamic Array Collection as its dataProvider. I
want to be able to edit the labels right in the Tree, and thereby edit the underlying data. However, I do not want to use the default Tree itemEditor functionality, which opens the editor on the itemClick Event. I want to be able to trigger the editor showing with my own custom Event. What is the easiest way to do this? I tried creating a custom itemRenderer, by extending the TreeItemRenderer Class, and setting the rendererIsEditor property to "true", but I could not get it to work correctly. If someone could point me in the right direction it would be greatly appreciated. Thank you. |
| Sponsored Links |
|
|||
|
Adobe Newsbot hopes that the following resources helps you. NewsBot is experimental and any feedback (reply to this post) on its utility will be appreciated:
Flex 3 - List control: You can pass a label function to the List control to provide logic that determines .... When you use an MXML component as a item renderer, it can contain Link: http://livedocs.adobe.com/flex/3/html/dpcontrols_2.html Flex 2.0 ItemRenderers: Jan 19, 2007 ... You'll see three items in the list with the text of the label property from your Array component. This view is the default view of a List Link: http://www.actionscript.org/resource...ers/Page1.html mx.controls.Label (Flex 3): When a component is used as a drop-in item renderer or drop-in item editor, Flex initializes the listData property of the component with the appropriate Link: http://livedocs.adobe.com/flex/3/lan...ols/Label.html Using a Slider control as a DataGrid column item renderer in Flex: The following example shows how you can use an HSlider control as an item renderer in a Flex DataGrid control. Full code after the jump. Link: http://blog.flexexamples.com/2008/05...derer-in-flex/ Using a custom item renderer -- Flex 2.01: When you use an MXML component as a item renderer, it can contain multiple levels ... iconField="myIcon"> <mx:dataProvider> <mx:Array> <mx:Object label="AL" Link: http://livedocs.adobe.com/flex/201/h...ls_062_04.html Disclaimer: This response is generated automatically by the Adobe NewsBot based on Adobe [L=Community Engine]http://community.adobe.com/ion/search.html[/L]. |
|
|||
|
I found a good workaround that didn't require too much code. I added an Event
Listener for the itemEditBeginning event. In the Event Handler, I have a condition that checks for a custom "reason" on the event. In the default event dispatched by the Tree, this reason is null, so all I have to do is dispatch an event manually in ActionScript (my function is triggered by a ContextMenu selection) with a reason that I specify, and if the reason is not the one I specify, I stop the Event from propogating. Hope this helps someone else someday... <?xml version="1.0" encoding="utf-8"?> <mx:Tree xmlns:mx="http://www.adobe.com/2006/mxml" editable="true" dataProvider="{myDP}" itemEditBeginning="reportsTree_itemEditBeginningHa ndler(event);" creationComplete="creationCompleteHandler();"> <mx:Script> <![CDATA[ import mx.events.ListEvent; private function creationCompleteHandler():void { var contextMenu:ContextMenu = new ContextMenu(); contextMenu.hideBuiltInItems(); contextMenu.addEventListener(ContextMenuEvent.MENU _SELECT, contextMenu_menuSelectHandler); this.contextMenu = contextMenu; } private function contextMenu_menuSelectHandler(event:ContextMenuEve nt):void { this.contextMenu.customItems = []; var editMenuItem:ContextMenuItem = new ContextMenuItem("Edit...", false, true); editMenuItem.addEventListener(ContextMenuEvent.MEN U_ITEM_SELECT, editMenuItemSelectHandler); this.contextMenu.customItems.push(renameMenuItem); } private function editMenuItemSelectHandler(event:ContextMenuEvent): void { var event:ListEvent = new ListEvent(ListEvent.ITEM_EDIT_BEGINNING, false, false, 0, this.selectedIndex, "myCustomReason"); this.dispatchEvent(event); } private function itemEditBeginningHandler(event:ListEvent):void { if (event.reason != "myCustomReason") event.preventDefault(); } ]]> </mx:Script> </mx:Tree> |
![]() |
| Thread Tools | |
| Display Modes | |
|
|
- Contact Us
-|-
Adobe Dreamweaver Forums -|-
Archive -|-
Top -|-Rules/Disclaimer-|-Help/Support-|-Advertise