0 Replies Latest reply on Mar 8, 2008 7:40 AM by VipersG

    Combobox/Tree Hybrid preselected value

    VipersG Level 1
      So here's the problem.

      I'm using Kurt Mossman's TreeCombobox
      which you can view here - http://kmossman.blogspot.com/2007/03/blog-post.html
      and the source for which is below:

      <----------------------------------------TreeCombobox------------------------------------- --->
      <?xml version="1.0" encoding="utf-8" ?>
      <mx:ComboBox xmlns:mx=" http://www.adobe.com/2006/mxml" >

      <mx:Script>
      <![CDATA[

      import mx.events.FlexEvent;

      [Bindable]
      private var _label:String;

      [Bindable]
      public var treeSelectedItem:Object;

      public function updateLabel(event:*):void{
      _label = event.currentTarget.selectedItem[this.labelField];
      treeSelectedItem = event.currentTarget.selectedItem;
      }

      override protected function updateDisplayList(unscaledWidth:Number,
      unscaledHeight:Number):void
      {
      super.updateDisplayList(unscaledWidth, unscaledHeight);

      if(dropdown && _label != null){
      text = _label;
      }
      }


      ]]>
      </mx:Script>
      <mx:dropdownFactory>
      <mx:Component>
      <mx:Tree change="outerDocument.updateLabel(event)" height="300" width="100%" />
      </mx:Component>
      </mx:dropdownFactory>
      </mx:ComboBox>
      <--------------------------------------EndTreeCombobox------------------------------------ -->

      It work's like an absolute charm until I want to load it with a predetermined value. Just as a combobox it will accept a selectedIndex property, but this alone wont do the trick as I also need to call the expandItem() method in the tree component.

      I've tried a few different approaches, none of which have worked. So I thought I'd throw it out here - Any suggestions?