2 Replies Latest reply on Mar 19, 2007 5:29 PM by ntsiii

    get reference to the itemEditor in Tree

    LevV Level 1
      I'm trying to reference the itemEditor on an edited item in the Tree. The Tree is bound to an ArrayCollection, a component based on TextInput is used as itemEditor. When I try to reference the itemEditor in the itemEditEnd event handler, I get a null reference error. The code is below, any ideas are greatly appreciated.

      // tree
      <mx:Tree id="folderTree"
      editable="true"
      width="100%"
      height="100%"
      selectedIndex="0"
      dataProvider="{Folders}"
      creationComplete="startService()"
      itemClick="treeItemClick(event)"
      itemEditEnd="renameFolder(event)"
      itemEditor="components.TreeNodeEditor"
      editorDataField="newName"
      labelField="Name">
      </mx:Tree>

      // event handler
      private function renameFolder(event:ListEvent):void
      {
      FolderID = event.target.selectedItem.ID;
      var editor:TreeNodeEditor = event.target.itemEditor as TreeNodeEditor;
      var name:String = editor.newName;
      }

      // itemEditor component
      <mx:VBox xmlns:mx=" http://www.adobe.com/2006/mxml" horizontalAlign="center" verticalAlign="middle">
      <mx:Script>
      <![CDATA[
      public function get newName ():String
      {
      return nodeEditor.text;
      }
      ]]>
      </mx:Script>
      <mx:TextInput xmlns:mx=" http://www.adobe.com/2006/mxml" id="nodeEditor" text="{data.Name}" />
      </mx:VBox>