DropDownList / ComboBox DataProvider Issue

In this example I have an ArrayCollection (values) that serves as a DataProvider and a Bindable field (value).  I would like to twoWay bind the value and dynamically load the values.  When dynamically loading the values, my bounded value is null.
I have two applications below, in the first example the dataprovider is initialized with all its values and the behavior is correct:
<?xml version="1.0"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark">
  <s:layout>
    <s:VerticalLayout/>
  </s:layout>
  <fx:Declarations>
    <fx:String id="value">B</fx:String>
    <s:ArrayCollection id="values">
      <fx:String>A</fx:String>
      <fx:String>B</fx:String>
      <fx:String>C</fx:String>
    </s:ArrayCollection>
  </fx:Declarations>
  <s:ComboBox id="comboBox" selectedItem="@{value}" dataProvider="{values}"/>
  <s:TextInput text="@{value}"/>
</s:Application>
In the second example the dataprovider is loaded dynamically, which is typical for a data driven application.  Now the bounded value is lost:
<?xml version="1.0"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark">
  <fx:Script><![CDATA[
    private function comboxCreated():void {
      values.addItem("A");
      values.addItem("B");
      values.addItem("C");
    ]]></fx:Script>
  <s:layout>
    <s:VerticalLayout/>
  </s:layout>
  <fx:Declarations>
    <fx:String id="value">B</fx:String>
    <s:ArrayCollection id="values"/>
  </fx:Declarations>
  <s:ComboBox id="comboBox" selectedItem="@{value}" dataProvider="{values}" creationComplete="comboxCreated()"/>
  <s:TextInput text="@{value}"/>
</s:Application>
Is there any recommended / elegant solution to fix this issue?
Kind Regards

I tried this and it seems to work fine - just moved the setting of the value of "value" to the creationComplete handler:
<?xml version="1.0"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark">
  <fx:Script>
                    <![CDATA[
                              private function comboxCreated():void {
                                        values.addItem("A");
                                        values.addItem("B");
                                        values.addItem("C");
                                        value="B";
                    ]]>
  </fx:Script>
  <s:layout>
  <s:VerticalLayout/>
  </s:layout>
  <fx:Declarations>
  <s:ArrayCollection id="values"/>
  <fx:String id="value"/>
  </fx:Declarations>
          <s:ComboBox id="comboBox" selectedItem="@{value}" dataProvider="{values}" creationComplete="comboxCreated()"/>
          <s:TextInput text="@{value}"/>
</s:Application>

Similar Messages

  • ComboBox fullscreen issue

    Short version: ComboBox's dropdown works and renders  properly before fullscreen, but not during or after.
    I'm not  totally sure how to ask this, so I've actually made a page demonstrating the  error, with a very simple Flex app, and all three directions you  need to experience the problem yourself.
    For those of you not daring enough  to follow my link above, I'll do my best to explain here. I've built a  more extensive Flex application (not the one in the link) that has some  graphs and charts and checkboxes and other controls for those charts. At  the bottom of app in a few of the application States, there is a ComboBox.  Because this is at the very bottom, when you click it to access it's dropdown menu, Flex thoughtfully has it come out of the top.  Yay, Flex!
    This works  well until Fullscreen mode. Upon entering fullscreen, I scale everything  up with a stage.scaleMode = StageScaleMode.SHOW_ALL. Now when you  click on the ComboBox, the dropdown is astonishingly large, and  actually drops beneath the ComboBox, causing it to mostly disappear  off-screen. The best part is, once you exit fullscreen mode, the  dropdown insists on continuing to drop below the ComboBox, which is  positioned at the bottom of the app, and so continues to be cut off.
    Has anyone else run into this beast, stared into it's great maw, and come away victorious?  Am I doing fullscreen mode wrong?  Please help!
    You can get the source code via View Source from the Flash player in the link, and thank you so much for your time.

    Thanks for the prompt reply!
    Here is a link to my identical, but two week old post on the Flex forums: [Flex] ComboBox fullscreen issue.  I believe the answer to your question is "no".
    Additionally, I have filed a bug report under the Flash player category to this effect, as well as doppelganger posts on Stack Overflow and Flexcoders.  This is the first human response I've gotten on this issue to date, but I did earn an S.O. badge for having no responses for such an extended period of time.
    I posted here after this prolonged duration of nothing, and because I thought perhaps it wasn't an issue with the language, but rather the way it was rendered in the player.  I have no idea where I should be getting answers for this from, but the problem isn't going away on it's own or through my repeated attempts at a solution.  So if this helps me even get directed to the right place, I will be grateful.
    Thank you!

  • Relationship between a Spark DropDownList's dataProvider and selectedItem

    I'm working on an existing project and have come across a somewhat complicated issue regarding a Spark DropDownList's (actually, a custom component inheriting from it) displayed item not changing when its dataProvider is updated.
    Here's the code for the custom TitleWindow component containing the custom DropDownList:
    <?xml version="1.0" encoding="utf-8"?>
    <components:RFTitleWindow xmlns:fx="http://ns.adobe.com/mxml/2009"
                              xmlns:s="library://ns.adobe.com/flex/spark"
                              xmlns:mx="library://ns.adobe.com/flex/mx"
                              xmlns:components="components.*"
                              xmlns:rfform="rfform.*"
                              width="550" height="450"
                              title="{currentState} Site Equipment"
                              cancelButton="{btnCancel}"
                              defaultButton="{btnSave}"
                              initialFocus="{rftName}"
                              creationComplete="init()" close="cancelEdit()">
      <fx:Script>
        <![CDATA[
          import events.SiteEquipmentEvent;
          import events.SiteEquipmentTypeEvent;
          import mx.collections.ArrayList;
          import mx.controls.Menu;
          import mx.core.FlexGlobals;
          import mx.core.UIComponent;
          import mx.events.MenuEvent;
          import mx.managers.PopUpManager;
          import mx.validators.ValidationResult;
          import mx.validators.Validator;
          import spark.events.IndexChangeEvent;
          private const TYPES:Array = ["A", "B", "C", "D"];
          [Bindable] [Embed(source="../assets/images/circle_red_x.gif")] private var icoRedX:Class;
          [Bindable] private var siteEquipment:SiteEquipment;
          private var validators:Array;
          private var typePopUp:Menu;
          public static function open(item:SiteEquipment):SiteEquipmentEdit
            var s:SiteEquipmentEdit = new SiteEquipmentEdit();
            s.siteEquipment = item;
            PopUpManager.addPopUp(s, DisplayObject(FlexGlobals.topLevelApplication), true);
            PopUpManager.centerPopUp(s);
            return s;
          private function init():void
            initTypePopUp();
            if (siteEquipment.id == SiteEquipment.NEW_ID)
              currentState = "New";
            else
              currentState = "Edit";
              validateAll();
              if (!rftName.enabled)
                rfcmbType.setFocus();
            siteEquipment.addEventListener(SiteEquipmentEvent.SITE_EQUIPMENT_SAVE, saveComplete);
          override public function dispose(event:Event = null):void
            super.dispose();
            siteEquipment.removeEventListener(SiteEquipmentEvent.SITE_EQUIPMENT_SAVE, saveComplete);
            typePopUp.removeEventListener("itemClick", typePopUp_click);
            siteEquipment.dispose();
            icoRedX = null;
            siteEquipment = null;
            validators = null;
            typePopUp = null;
            removeChildren();
          private function cancelEdit():void
            siteEquipment.cancelEdit();
          private function saveForm():void
            var newValue:SiteEquipment = new SiteEquipment();
            newValue.id = siteEquipment.id;
            newValue.locid = siteEquipment.locid;
            newValue.name = rftName.trimmedText;
            siteEquipment.save(newValue);
          private function saveComplete(event:Event):void
            dispose();
          private function typePopUp_click(event:MenuEvent):void
            switch(event.item)
              case "Edit Selected Type":
                SiteEquipmentType(rfcmbType.selectedItem).showEditForm();
                break;
              case "Create A New Type":
                new SiteEquipmentType().showEditForm(type_created, null, type_removeListeners);
                break;
          private function type_created(event:SiteEquipmentTypeEvent = null):void
            type_removeListeners(event);
            rfcmbType.selectedItem = event.siteEquipmentType;
          private function type_removeListeners(event:Event):void
            var s:SiteEquipmentType = SiteEquipmentType(event.target);
            s.removeEventListener(SiteEquipmentTypeEvent.SITE_EQUIPMENT_TYPE_CREATE, type_created);
            s.removeEventListener(SiteEquipmentType.SITE_EQUIPMENT_TYPE_CANCEL, type_removeListeners);
          private function initTypePopUp():void
            typePopUp = Menu.createMenu(puType, ['Edit Selected Type', 'Create A New Type']);
            typePopUp.addEventListener("itemClick", typePopUp_click);
          private function popupTypeOptions():void
            var p:Point = puType.localToGlobal(new Point(0, puType.height + 5));
            typePopUp.show(p.x, p.y);
          private function validateAll():void
            var isValid:Boolean;
            for each (var validator:Validator in validators)
              isValid = true;
              for each (var result:ValidationResult in validator.validate().results)
                if (result.isError)
                  isValid = false;
                  break;
              UIComponent(validator.source).styleName = "valid_" + isValid.toString();
          private function rfcmbType_changeHandler(event:IndexChangeEvent):void
            if (TYPES.indexOf(SiteEquipmentType(RFDropDownList(event.target).selectedItem).name) > -1)
              rftName.text = "Blah";
              rftName.enabled = false;
            else
              rftName.enabled = true;
        ]]>
      </fx:Script>
      <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
        <s:DateTimeFormatter id="mdy"
                             dateTimePattern="MM/dd/yyyy"/>
      </fx:Declarations>
      <components:states>
        <s:State name="Edit"/>
        <s:State name="New"/>
      </components:states>
      <rfform:RFForm width="100%" height="100%"
                     saveButton="{btnSave}"
                     validators="{new ArrayList([valQuantity, valHeight])}">
        <rfform:RFFormItem label="Type"
                           width="100%">
          <s:HGroup width="100%">
            <rfform:RFDropDownList id="rfcmbType"
                                   width="100%"
                                   originalValue="{siteEquipment.model.eqType}"
                                   dataProvider="{SiteEquipmentType.all}"
                                   change="rfcmbType_changeHandler(event)"/>
            <rfform:RFButton id="puType"
                             icon="@Embed(source='/Shared/src/assets/images/settings.png')"
                             width="30"
                             click="popupTypeOptions()"/>
          </s:HGroup>
        </rfform:RFFormItem>
      </rfform:RFForm>
    </components:RFTitleWindow>
    I've omitted a little bit of code, so please ask if you need anything that I didn't include.
    In regards to the RFDropDownList, originalValue is saved so that when a new selection is made, the new selection can be compared to the original value.  Setting originalValue sets the RFDropDownList's selectedItem to originalValue.
    When this window is first opened, a new instance of SiteEquipment is created.  Unless the equipment is new, the SiteEquipment instance sets the SiteEquipmentType to whatever has already been saved, using this line:
    eqType = SiteEquipmentType.selectFromObject(item.SITE_EQUIPMENT_TYPE);
    And here's the code from the SiteEquipmentType class:
    package components
      import common.UpdateStatus;
      import events.SiteEquipmentTypeEvent;
      import scripts.MyUtility;
      import flash.events.Event;
      import flash.events.EventDispatcher;
      import flash.utils.setTimeout;
      import mx.collections.ArrayCollection;
      import mx.collections.Sort;
      import mx.collections.SortField;
      import mx.controls.Alert;
      import mx.rpc.events.ResultEvent;
      import mx.utils.ObjectProxy;
      [Event(name="cacheChanged", type="flash.events.Event")]
      [Event(name="SITE_EQUIPMENT_TYPE_CREATE", type="events.SiteEquipmentTypeEvent")]
      [Event(name="SITE_EQUIPMENT_TYPE_EDIT", type="events.SiteEquipmentTypeEvent")]
      [Event(name="SITE_EQUIPMENT_TYPE_CANCEL", type="flash.events.Event")]
      public class SiteEquipmentType extends ObjectProxy
        public static const NEW_ID:int = -1;
        public static const SITE_EQUIPMENT_TYPE_CANCEL:String = "siteEquipmentTypeCancel";
        [Bindable]
        public var id:int = NEW_ID;
        [DefaultProperty]
        [Bindable]
        public var name:String = "";
        private static var dict:Object = new Object();
        private static var getAllServiceCalled:Boolean = false;
        private static var eventDispatcher:EventDispatcher = new EventDispatcher();
        private var updateStatus:UpdateStatus = UpdateStatus.COMPLETE;
        public function SiteEquipmentType(item:Object = null, keepInCache:Boolean = true)
          if (item == null)
            return;
          else if (item is int)
            id = int(item);
            refreshFromDb();
          else
            updateFromResult(item);
          if (keepInCache)
            addToCache(this);
        private static var _all:ArrayCollection = new ArrayCollection();
        public static function get all():ArrayCollection
          if (!getAllServiceCalled)
            getAllServiceCalled = true;
            MyUtility.httpPost("/page.aspx", {request:"SITE_EQUIPMENT_TYPE"}, getAll_result);
            var s:Sort = new Sort();
            s.fields = [new SortField("name", true)];
            _all.sort = s;
          return _all;
        public static function addEventListener(type:String, listener:Function):void
          eventDispatcher.addEventListener(type, listener);
        public static function removeEventListener(type:String, listener:Function):void
          eventDispatcher.removeEventListener(type, listener);
        public static function dispatchEvent(event:Event):Boolean
          return eventDispatcher.dispatchEvent(event);
        private static function addToCache(item:SiteEquipmentType):void
          removeFromCache(item.id);
          dict[item.id] = item;
          _all.addItem(item);
          dispatchEvent(new Event("cacheChanged"));
        private static function removeFromCache(id:int):void
          var item:SiteEquipmentType = dict[id];
          if (item)
            delete dict[id];
            _all.removeItemAt(_all.getItemIndex(item));
        public static function selectById(id:int):SiteEquipmentType
          if (dict[id])
            return dict[id];
          return new SiteEquipmentType(id);
        public static function selectFromObject(obj:Object):SiteEquipmentType
          var selected:SiteEquipmentType;
          var objId:int = obj.SITE_EQUIPMENT_TYPE_ID;
          if (dict[objId])
            selected = dict[objId];
            selected.updateFromResult(obj);
          else
            selected = new SiteEquipmentType(obj);
          return selected;
        private function updateFromResult(item:Object):void
          if (item)
            id = item.SITE_EQUIPMENT_TYPE_ID;
            name = item.SITE_EQUIPMENT_TYPE_NAME;
        private function toRequestObject():Object
          var o:Object = new Object();
          o.SITE_EQUIPMENT_TYPE_ID = id;
          o.SITE_EQUIPMENT_TYPE_NAME = name;
          return o;
        public function copy():SiteEquipmentType
          return new SiteEquipmentType(this.toRequestObject());
        public function save(value:SiteEquipmentType):void
          if (updateStatus == UpdateStatus.PENDING)
            Alert.show("Site Equipment Type is pending an update.", "Pending Update");
            return;
          else if (updateStatus == UpdateStatus.ERROR)
            Alert.show("There is a problem with this Site Equipment Type, and it cannot be saved. Please close the window.", "Save Failure");
            return;
          var request:Object;
          if (id == NEW_ID)
            if (value)
              request = value.toRequestObject();
            else
              request = toRequestObject();
            request._COMMAND = "INSERT";
          else
            if (value)
              request = MyUtility.objectDiff(this.toRequestObject(), value.toRequestObject());
              if (!request)
                dispatchEvent(new SiteEquipmentTypeEvent(SiteEquipmentTypeEvent.SITE_EQUIPMENT_TYPE_CREATE, this));
                return;
            else
              request = toRequestObject();
            request._COMMAND = "UPDATE";
            request._SITE_EQUIPMENT_TYPE_ID = id;
          delete request.SITE_EQUIPMENT_TYPE_ID;
          updateStatus = UpdateStatus.PENDING;
          MyUtility.httpPost("/updatetable.aspx?_SCHEMA=dbo&_TABLENAME=SITE_EQUIPMENT_TYPE&_RETURNRECORD=1", request, httpSave_result);
        public function toString():String
          return name;
        public function refreshFromDb():void
          if (updateStatus != UpdateStatus.PENDING)
            updateStatus = UpdateStatus.PENDING;
            MyUtility.httpPost("/page.aspx", {id:id, request:"Site_Equipment_Type"}, httpSelect_result);
        public function showEditForm(onCreate:Function = null, onEdit:Function = null, onCancel:Function = null):void
          if (id == 0)
            Alert.show("Edits are not allowed on this Site Equipment Type.", "Not Allowed");
            return;
          if (onCreate != null)
            addEventListener(SiteEquipmentTypeEvent.SITE_EQUIPMENT_TYPE_CREATE, onCreate);
          if (onEdit != null)
            addEventListener(SiteEquipmentTypeEvent.SITE_EQUIPMENT_TYPE_EDIT, onEdit);
          if (onCancel != null)
            addEventListener(SITE_EQUIPMENT_TYPE_CANCEL, onCancel);
          if (updateStatus == UpdateStatus.PENDING)
            setTimeout(showEditForm, 500);
          else if (updateStatus == UpdateStatus.COMPLETE)
            SiteEquipmentTypeEdit.open(this);
        public function cancelEdit():void
          dispatchEvent(new Event(SITE_EQUIPMENT_TYPE_CANCEL));
        private static function getAll_result(event:ResultEvent):void
          if (event.result.ROOT)
            if (event.result.ROOT.ERROR)
              Alert.show(event.result.ROOT.ERROR, "Error");
            else
              for each (var o:Object in MyUtility.ToArrayCollection(event.result.ROOT.SITE_EQUIPMENT_TYPE))
                var i:SiteEquipmentType = dict[o.SITE_EQUIPMENT_TYPE_ID];
                // If the Site Equipment Type is already in the cache, update it based on the XML returned
                if (i)
                  i.updateFromResult(o);
                  // Otherwise, create a new one from the XML returned
                else
                  i = new SiteEquipmentType(o);
              _all.refresh();
        private function httpSelect_result(event:ResultEvent):void
          if (event.result.ROOT)
            if (event.result.ROOT.ERROR)
              Alert.show(event.result.ROOT.ERROR, "Error");
              updateStatus = UpdateStatus.ERROR;
            else
              updateFromResult(event.result.ROOT.SITE_EQUIPMENT_TYPE);
              updateStatus = UpdateStatus.COMPLETE;
          else
            updateStatus = UpdateStatus.ERROR;
        private function httpSave_result(event:ResultEvent):void
          if (event.result.ROOT.ERROR)
            Alert.show(event.result.ROOT.ERROR, "Error");
            updateStatus = UpdateStatus.ERROR;
          else
            try
              updateStatus = UpdateStatus.COMPLETE;
              if (id == NEW_ID)
                id = event.result.ROOT.RESULTS.IDENTITY;
                addToCache(this);
                updateFromResult(event.result.ROOT["DBO.SITE_EQUIPMENT_TYPE"]);
                dispatchEvent(new SiteEquipmentTypeEvent(SiteEquipmentTypeEvent.SITE_EQUIPMENT_TYPE_CREATE, this));
              else
                updateFromResult(event.result.ROOT["DBO.SITE_EQUIPMENT_TYPE"]);
                dispatchEvent(new SiteEquipmentTypeEvent(SiteEquipmentTypeEvent.SITE_EQUIPMENT_TYPE_EDIT, this));
                SiteEquipmentType.dispatchEvent(new SiteEquipmentTypeEvent(SiteEquipmentTypeEvent.SITE_EQUIPMENT_TYPE_EDIT, this));
            catch(ex:Error)
              Alert.show(ex.message, "Error");
              updateStatus = UpdateStatus.ERROR;
    So the "_all" ArrayCollection serves as a cache of all of the different site equipment types.  When the edit window is first opened and a new instance of SiteEquipment is created, the SiteEquipmentType of the current SiteEquipment is added to _all and becomes the only SiteEquipmentType within _all.
    At this point, the DropDownList has the correct item selected.  The problem occurs when the result comes in from getting all of the SiteEquipmentTypes.  The contents of _all are flushed, and each SiteEquipmentType is added in.  Once this happens, the DropDownList will have nothing for selectedItem.
    I know this is quite complex, but any help would be greatly appreciated.

    Ok, I have this figured out now.  First, though, I'll point out that this worked fine when using MX components and the Halo theme; the problem only appeared after switching over to Spark components and the Spark theme.  Anyway, since this class functions as a singleton (as best I understand them), I added a boolean variable to the SiteEquipmentType class representing whether or not the results from the HTTPService call had come back and been inserted into _all.  So in the TitleWindow's init method, I only populated the DropDownList's originalValue (which in turn sets the selectedItem) if that variable is true.  The first time an instance of the TitleWindow component is opened, though, this variable will initially be false.  So back in the SiteEquipmentType class, I have it dispatch an event right after setting the variable to true, and the TitleWindow componet will add a listener for this event if the variable is originally false.  If anyone needs further explanation, please ask.

  • Spark ComboBox click issue

    I'm using a spark combobox in my AdvancedDataGrid, as an itemEditor. At some point I noticed that clicking on the scroll bar arrows would close the CB - very annoying. After much research I found this which completely solved my problems - awesome!
    One more and last lingering issue left though: when selecting an item from an open dropdownlist the mouse click seems to propagate to the cell below once the dropdown has closed. I assumed that the fix above would take care of this last issue, but it doesn't seem to. I tried to override the item_mouseDownHandler for the CB and stopImmediatePropagation() of the mouse event post its usual behavior, but that also seems to have no effect. I also tried setting the mouseChildren property for the skin['dropDown'] to false, but that impairs the whole functionality.
    Would love any help / suggestions.
    thank you all, as always
    f

    I'm not sure. Happy to try this out and post code if it helps debugging the issue, but I'm stuck with an ADG, so switching to DG would not be an option for me.

  • DataGrid Combobox dataprovider erasing items

    I have a DataGrid that is linked to an array of custom data objects which I call a seriesList.  You are supposed to be able to choose the name of each series via a combobox in the datagrid.  It works fine except when the user selects the combobox and then clicks somewhere else in the interface, which closes the combobox and erases whichever item is previously selected!
    <!--  Definition in application  -->
    <!--  axis.seriesList is and ArrayCollection of actionscript objects called SeriesObjects which have a var name:String variable -->
    <mx:DataGrid id="seriesTable" color="black" fontSize="9" rowHeight="30" editable="true" resizeEffect="slow" rollOverColor="#CCCCCC"
        selectionColor="#999999" dataProvider="{axis.seriesList}" width="100%"
        rowCount="{axis.seriesList.length > 2 ? axis.seriesList.length : 2}" >
            <mx:columns>  
                 <mx:DataGridColumn dataField="name" headerText="Name" width="280" headerStyleName="centered" id="nameColumn"
                         rendererIsEditor="true"  editorDataField="result" itemRenderer="renderer.SeriesBoxRenderer"/>
            </mx:columns>
    </mx:DataGrid>
    <!--  SeriesBoxRenderer -->
    <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="init()" horizontalAlign="center">
       <mx:Script>
            <![CDATA[
                import mx.collections.ArrayCollection;
                // Define a property for returning the new value to the cell.
                public var result:String="";
                [Bindable]
                private var dpValue:ArrayCollection;
                private function init():void {
                    // list of possible names to choose from for this series
                    dpValue = mx.core.Application.application.seriesArray;
                // Override the set method for the data property.
                override public function set data(value:Object):void {
                    if (dpValue == null) init();
                    super.data = value;
                    if (value != null)     {
                        var currentValue:String = value.name;
                        var len:int = dpValue.length;
                        for (var i:int = 0; i < len; i++) {
                            if (dpValue[i].name == currentValue) {
                                editor.selectedIndex = i;
                                return;
                    editor.selectedIndex = 0;            }
                public function onChange():void {
                    var index:int = editor.selectedIndex;
                    result = dpValue[index].name;
                    data.name = dpValue[index].name;
            ]]>
        </mx:Script>
         <mx:ComboBox id="editor" textAlign="left" labelField="name" dataProvider="{dpValue}"  change="onChange()"/>
    </mx:VBox>

    I'm thinking the problem may be the dataprovider for the combobox.  This array is also shared with another List component in another tab on the interface.  The reason I am thinking this is because I have another item renderer which uses a combobox and does not erase itself when you click nothing.  Here is the code for that item, and the only difference I can see between this code and the code that doesn't work is the fact that the dataprovider is shared with another part of the code.  Still not sure how to fix this, however.
              [Bindable]
                private var dpValue:ArrayCollection;
                private function init():void {
                    dpValue = mx.core.Application.application.aquisitionOptions.lastResult.system.data;
                    for ( var i:int=0; i<dpValue.length; i++ )  {  //loop over the items in the dataProvider
                       if (dpValue[i].id == data.aquisitionID)  {  //compare desired value to current item.data value
                            editor.selectedIndex = i;  //set the seletedIndex of the combo box
                            data.aquisitionDescr = dpValue[i].name;
                            break;
              // Override the set method for the data property.
                override public function set data(value:Object):void {
                    super.data = value;
                    if (dpValue == null) init();
                    if (value != null)     {        
                        var currentValue:String = value.aquisitionDescr;
                        trace ("\n current:  ", currentValue);
                        var len:int = dpValue.length;
                        for (var i:int = 0; i < len; i++) {
                            if (dpValue[i].name == currentValue) {
                                editor.selectedIndex = i;
                                return;
                    editor.selectedIndex = 0;
                public function onChange():void {
                    var index:int = editor.selectedIndex;
                    result = dpValue[index].name;
                    data.aquisitionDescr = dpValue[index].name;
                    data.aquisitionID = editor.selectedItem.id as String;
            ]]>
        </mx:Script>
         <mx:ComboBox id="editor" labelField="name" dataProvider="{dpValue}" change="onChange()"/>
    <!-- definition in the datagrid -->
    <mx:DataGridColumn dataField="aquisitionDescr" headerText="Data Aquisition" width="160" headerStyleName="centered" id="acquisitionColumn"
                         rendererIsEditor="true"  editorDataField="result" itemRenderer="renderer.AquisitionBoxRenderer"/>

  • Formatting textfile for Combobox.dataProvider

    Can't seem to find any formatting rules for array
    construction through an external file.
    This is what i am trying to do:
    I've loaded vars into the _root this works fine. Splitted its
    value for constructing an array. This seems to work fine aswell.
    If I code the array within the fla in this format:
    my_dP= new Array(
    {label:"choose..."},
    {data:"
    http://www.myserver.com/netlabel/Johannes
    Lauxen.txt",label:"Johanes Lauxen"},
    {data:"
    http://www.myserver.com/netlabel/PQR1.txt",
    label:"PQR1"}
    and use this for the dataProvider for the combobox named
    my_cb like this:
    my_cb.dataProvider = my_dP;
    everything works fine.
    The problem is:
    But if I put this in the same formatting in the textfile for
    the array I create using split like I described above, the values
    for my labels in my_cb are this text, i mean it doesn't
    interpretate the loaded text as script, it just displays the code
    as labels.
    my textfile looks like this :
    &var2={label:"choose..."}#{data:"
    http://www.myserver.com/netla
    bel/Johannes Lauxen.txt",label:"Johanes
    Lauxen"}#{data:"
    http://www.myserver.com/netlabel/PQR1.txt",
    label:"PQR1"}&
    (O, the # is used for delimiter)
    How can i get this to work ? Or is it not the
    textfileformatting that causes the problem ?
    many thanks
    (flash8 b.t.w.)

    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" width="450" height="350">
        <mx:Script>
            <![CDATA[
                import mx.collections.ArrayCollection;
                [Bindable]
                private var types:Array = ['colors','numbers','shapes'];
                private var dataProviders:Object =
                    colors:['red','blue','green'],
                    numbers:['1','2','3'],
                    shapes:['circle', 'square','triangle']
                private function getItemDataProvider(type:Object):Array
                    return dataProviders[type] as Array;
            ]]>
        </mx:Script>
            <mx:ComboBox id="typeSelector" dataProvider="{types}"/>
            <mx:ComboBox id="itemSelector" dataProvider="{getItemDataProvider(typeSelector.selectedItem)}"/>
    </mx:Application>

  • ComboBox onEnterFrame Issue

    Hi,
    I have created an email form in one swf that is called into
    another swf. In this form there is a comboBox that will populate a
    text field when something is selected in it. Everything works fine
    with the comboBox in it's own swf but when it's called into another
    swf the comboBox is inactive. I'm not sure but I think it may have
    to do with the onEnterFrame.... here is the code from the swf that
    contains the comboBox and email information.
    import mx.remoting.Service;
    import mx.services.Log;
    import mx.rpc.RelayResponder;
    import mx.rpc.FaultEvent;
    import mx.rpc.ResultEvent;
    import mx.remoting.PendingCall;
    import mx.remoting.RecordSet;
    import mx.remoting.DataGlue;
    onEnterFrame = function(){
    area_ta.text = area_cb.value;
    submit_btn.onRelease = function() {
    if (question1_txt.text == "") {
    gotoAndStop ("error");
    }else{
    var pc:PendingCall = myService.mailSuggestion
    (question1_txt.text, area_cb.value);
    pc.responder = new RelayResponder (this,
    "mailSuggestion_Result","mailSuggestion_Fault");
    gotoAndStop ("correct");
    var myService : Service = new Service("
    http://******flashservices/gateway",
    new Log (Log.DEBUG),
    "tap.*******.emailfunction",
    null,
    null);
    stop();

    Thanks for helping me with this by the way...
    Ok I added the listener and that worked in it's own swf, but
    same issue when I pull from the main swf. I'll try putting it in
    the main swf but I would like to keep it in the one its in.
    Picture a website and when you click on Ask The Trainer
    button that calls a swf and in this swf there will be a combobox to
    select what area you are from and a text box that you will fill in
    your question in and then click submit. That sends an email
    containing the info from the combobox and the text field. So I
    would need them all in the same swf, wouldn't I?

  • Setting Combobox 'dataProvider' @runtime and using 'labelFunction'

    I have 2 comboboxes which are related i.e. when i change cb-1 i need to display values in cb-2 (cb-2 list varies with the value selected). I have simplified my case but this is what my problem is. After i set 'cb-2.dataProvider' when does 'labelFunction' for cb-2 get called?
    If i am not clear enough please let me know. Here is the code.....
    private function cb-1Change(event:ListEvent):void
    {// This will be a dynamic one using the value selected in cb-1
    cb-2.dataProvider = __model.someList.getItemAt(0).cb-2VOList;  // extracting from a Map kind object
    // This Label function is never getting called
    private function displayCB-2Label(item:Object):String{ 
         // something
    <mx:ComboBox d="cb-1"           dataProvider="{__model.cb-1List}"
              change="cb-1Change(event)"
    />
    <mx:ComboBox d="cb-2"
              labelFunction="displayCB-2Label(event)"
              change="cb-1Change(event)"
    />
              change="cb-1Change(event)"
    />  

    Ryan,
            Thanks for the answer. I think i was not clear on my questions. Let me try it again:
    Requirement:
           When ever user change cb-1 value it should populate a new list and assign to cb-2 dataProvider i.e. cb-2 list should refresh. cb-2 needs to display right label based on its 'labelFunction'.
    cb1 -  List of Strings
    cb2 -  List of VO's in the following format
    ListVO:
           public var code:String;    // This Code is what user selects in cb-1
           public var  listValues:ArrayCollection;  // List of PlainVO's
    PlainVO:
         public var name:String;
         public var value:String;
    Also from your answer how can i call 'cb-2 label function in cb-1 change', i mean cb-2 labelFunction expects current 'ListVO' object...right?

  • Webservice as Combobox dataprovider

    Does anyone have an example of how to use a webservice as a
    dataprovider to a combobox?
    I would like to see how to set the label and data values for
    the combobox lookup list.
    Thank you ahead of time.
    Bill Brittain

    You need a little function to find the index of the item in
    the data provider and then sets the combo box's selected index to
    that number. This example uses the
    label, but you just as easily use the
    data.
    label
    public function setSelectedLabel(label:String):void
    for(var i:int=0; i< this.dataProvider.length; i++)
    if(this.dataProvider.label==label)
    this.selectedIndex=i
    simon

  • ArrayCollection field as ComboBox dataProvider question

    I have an ArrayCollection defined like this:
    public var test:ArrayCollection = new ArrayCollection([
    { Id:"one", Amount:2000 },
    { Id:"two", Amount:1000 },
    { Id:"three", Amount:200 } ]);
    And i would like to make 'Id' field of 'test' ArrayCollection
    as dataProvider for a ComboBox compoenent but can't figure it out
    how.I tried with following but get an error:
    comboName.dataProvider = test.Id;
    Can someone please help me with this?
    thanks in advance

    Dang, i totally forgot about 'labelField' property which
    solves the problem:
    comboName.labelField = "Id";
    :)

  • Combobox Selection Issue

    I have an application that populates combobox2 based off of the selection made in combobox1. When a selection in combobox1 is made, I call a function that connects to a database and gets a list of all compatible parts for the selection in combobox1 from the MySQL table. I read the result set into a vector. I then pass the vector to combobox2 and it displays the list. Everything works perfectly.
    The columns in MySQL are: sku, manufacturer, speed, cores, fsb, cache, l1,l2, compatible. I am puling out everything but the sku and compatible, and adding them to each row of the vector.
    The problem I have is that after the user picks the option they want and it is time to submit the form, I want to get the sku number associated with their selection. Unfortunately, I can't go back to the database, as the manufacturer, speed, cores, fsb, cache, l1 and l2 might match hundreds of records. (I am using the column called "compatible" to determine which records go with which combobox1 selections).
    What I can not seem to grasp, is what data structure I need to use to store the sku and the manufacturer/speed/cores/fsb/cache/l1/l2 so that they can be related to one another inside the combobox. I don't want to display the sku to the user, as that is unnecessary information.
    There is a way in VB.net to set a value for a selection in the combobox, so that what is selected and what is sent to the system can be different. I don't know if something like that exists in Java. I don't know if something like an ArrayList would be better.

    I may have just answered my own question. I can still go back to the database and pull the sku based on description, I just have to remember to include a check against the compatible list.(There should never been two rows with the exact same description for the exact same system.) However, that will require me to break out my string. See, when I read the a row into the vector I do:
    optionsVector.add(rs.getstring("manufacturer" + "speed" + "cores" + "fsb" + "cache" + "l1" + "l2");
    So in reverse I would have to break out the line "Intel, 2.5ghz, 4 cores, 800mhz, 8mb, 512k, 512k" into the original format and then search. Should be easier with the commas as delimiters. Still, seems like there should be an easier way.

  • WIN 8 IE11 problem in DropdownList (combobox) click event

    In Windows 7 IE11 everything worked as expected, but in Windows 8 using IE11, the list items can't be clicked and only the keyboard arrows working.
    What could be the reason?
    Thanks

    Hi Gbonaert,
    This kind of issue might be caused by incompatible add-ons or corruption during update.
    Reset Internet Explorer then check the issue again.
    http://windows.microsoft.com/en-us/internet-explorer/reset-ie-settings#ie=ie-11
    If the issue still persists
    Try disable/removing add-ons in your Internet Explorer, or you also could start Internet Explorer under no add-on mode.
    http://windows.microsoft.com/en-us/internet-explorer/manage-add-ons#ie=ie-11
    Regards,
    D. Wu
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact [email protected]

  • ComboBox width issue

    Hi:
    I have a popup window of a fixed size which is used through out the application. This popup has a combobox of a set width. But the length of label data in the box is longer than the width so data is always hidden. for example, say  my combobox width is set to 250 but the label width in the combobox could sometime be 500. How do I display the full label with a larger width keeping the actual combobox width to 250?
    Thanks in advance.
    KM

    Thanks a lot Flex HarUI for the quick and relevant reply. Appreciate it.

  • Combobox performance issue

    Dear All,
    Please let me know the fastest way to populate a combobox with values. Right now I am using the below code to populate the values in the combobox. I have some 1000 records to populate in the combobox. Its taking a lot of time to populate.
    Private Sub AddVillagesToCombo(ByRef oCombo As SAPbouiCOM.ComboBox)
            Dim RS As SAPbobsCOM.Recordset
            Dim Bob As SAPbobsCOM.SBObob
            RS = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
            Bob = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoBridge)
            RS.DoQuery("SELECT T0.[Code], T0.[U_Vilage] FROM [dbo].[@IS_VILLAGE]  T0 order by T0.[U_Vilage]")
            RS.MoveFirst()
            If oCombo.ValidValues.Count > 0 Then
                For i As Integer = 1 To oCombo.ValidValues.Count
                    oCombo.ValidValues.Remove(0, SAPbouiCOM.BoSearchKey.psk_Index)
                Next
            End If
            While RS.EoF = False
                oCombo.ValidValues.Add(RS.Fields.Item("U_Vilage").Value, RS.Fields.Item("Code").Value)
                RS.MoveNext()
            End While
            oCombo.ValidValues.Add("Define New", "Define New")
        End Sub
    Regards,
    Noor Hussain

    Hi noor,
    ZHANGLAN is absolutely correct. There is no good performance solution to load that many records onto a ComboBox.
    You can achieve a better solution to the one you have now, if you catch the form load event and insert the values into the XML form:
    <item uid="Report" type="113" left="620" ...  AffectsFormMode="0">
         <AutoManagedAttribute></AutoManagedAttribute>
         <specific AffectsFormMode="0" TabOrder="0">
              <ValidValues>
                   <action type="add">
                        <ValidValue value="1" description="Document"></ValidValue>
                        <!-- ADD Valid Values here... -->
                   </action>
              </ValidValues>
         <databind databound="1" table="" alias="Report"></databind>
         </specific>
    </item>
    But, for the best performance, I suggest you change your control to an EditText with a CFL.
    Regards,
    Vítor Vieira

  • Combobox refresh issue

    Hi,
    I have a combobox in my user defined form.
    Its value is getting refreshed normally.
    But, if you go to Find mode, and find a record, combo's value is not displayed.
    (It is blank)
    if you click on the combo, valid value is getting displayed.
    Please help me with this!
    Thanks in advance!

    did you apply a dbdatasource to the combobox field?
    Regards,
    WB

Maybe you are looking for

  • Dependant lovs in jsp with mysql data

    hi to all. here is my doubt How to create dependant dynamic list of values in jsp where the data comes from mysql tables.(I mean i am storing all the details in mysql tables using foreign keys etc..). Ex.:country--->state--->district--->city---> we w

  • Upgrade 12.0.4 to 12.0.6

    Dear Hussein, We have to upgrade 1204 to 1206(RUP6), please confirm me the following steps Pre-install Tasks 1.Apply the Patch R12.AD.A.DELTA.6 R12.AD.A.DELTA.6 (7305220) Pre-install Tasks for R12.AD.A.DELTA.6 7305220 Run perl $AD_TOP/bin/admsi.pl -p

  • Can one start Integration Process on it's own?

    Hi, we have requirement where Integration Process should make RFC call to R/3 system. And the return from RFC is then processed further in Integration Process. Actually there is infinite loop & wait steps in IP, within this infinite loop, we want to

  • Does any know anything about an Hand Held device that can be used for Racing Apps?

    I was reading a review of one of the Racing games from the Mac App store and someone mentioned something about an Hand Held Device. Look 4ward 2 hearing back from someone soon. Thanx

  • Installed airport extreme having range problems

    i have a mac osx and installed an airport extreme in my house, and wanted to extend the range down to my shop which is aprox 300 ft away. it is a wood building with windows. i bought a express and placed it in the window at the shop and the light doe