how to make a tree selectedNode editable on a button  click....

initially i tried it using myTree.selectedItem.editable=true;
but this doing somethi..... creating a new node with a leaf node......
i don know why its happening;

Also i did by using a item editor..... but i don know how to integrate
tat on a button click......


here is my code.......

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
layout="absolute">
<mx:XML id="treedata">
    <top label="node 0">
      <row label="node 1"></row>
      <row label="node 3"> </row>
      <row label="node 5"></row>
    </top>
  </mx:XML>

        <mx:Tree id="myTree"
        width="400" height="400"
        editable="true"
        itemEditor="Mycomponents.TreeRenderer"
        editorHeightOffset="2" editorWidthOffset="-225"
        editorXOffset="49" editorYOffset="25"
        creationComplete="initCatalog(treedata);"
        itemEditBeginning="disableEditing(event);"
        itemEditEnd="processData(event);" labelField="@label"/>


        <mx:Button x="524" y="120" label="Button" id="btn_add"
click="add_label(value)"/>


        <mx:Script>
                <![CDATA[
                        import mx.events.IndexChangedEvent;
                        import mx.events.ListEvent;
                        import mx.events.TreeEvent;
                        //import Tree.TreeRenderer;
                        import mx.controls.Alert;
                        import mx.controls.TextInput;
                        import Mycomponents.TreeRenderer;
                        //public var set:TreeRenderer;
                        [Bindable]
                        public var set_visible:Boolean=false;
                        public var value:String;

                        private function add_label(value:String):void
                        {

                                // [EMAIL PROTECTED]

                                     // 
nav.editedItemPosition={rowIndex:event.rowIndex}




                        }

                        private function initCatalog(cat:Object):void {
            myTree.dataProvider = cat;
        }

        // Define the event listener for the itemEditBeginning event
        // to disable editing when the user selects
        // the top node in the tree.
        private function disableEditing(event:ListEvent):void {
            if(event.rowIndex==0) {
                event.preventDefault();

            }
        }

        // Define the event listener for the itemEditEnd event
        // to copy the updated data back to the data provider
        // of the Tree control.
        public function processData(event:ListEvent):void {

            // Disable copying data back to the control.
            event.preventDefault();

            // Get new phone number from editor.
            [EMAIL PROTECTED] =
 
TreeRenderer(event.currentTarget.itemEditorInstance).contactPhone.text;

            value=event.toString()
            Alert.show(value);

            // Get new status from editor.


            // Close the cell editor.
           // myTree.destroyItemEditor();

            // Notify the list control to update its display.
        //
myTree.dataProvider.notifyItemUpdate(myTree.editedItemRenderer);
        }


                ]]>
        </mx:Script>
        <mx:Tree x="460" y="266"></mx:Tree>
</mx:Application>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Flex 
India Community" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/flex_india?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to