0 Replies Latest reply on Jul 31, 2008 8:53 AM by Cr99

    State change and data binding

    Cr99 Level 1
      I have a custom component (DisplayFields) with various fields and buttons. At times during my application, these components are added. The data for the fields is generated from another custom component (DataObject) with information like strings, arrays, etc. The problem I'm having is with databinding the array to a DataGrid. Heres the overview of what happens.

      var df:DisplayField = new DisplayField();
      // ... then add it to the interface .. //
      df.setData(dataList.getItemAt(i) as DataObject); //

      Here is some snippets from DataObject (most importantly the setData function):

      <mx:states>
      <mx:State name="functionView">
      <mx:AddChild relativeTo="{mainBox}" position="lastChild">
      <mx:HBox id="funcBox" verticalAlign="bottom" addedEffect="downWipe" creationPolicy="all">

      <mx:DataGrid visible="{applyFunc.selected}" editable="true" id="funcTable" dataProvider="{data.functions}">
      <mx:columns>
      <mx:DataGridColumn dataField="name" />
      <mx:DataGridColumn dataField="val" />
      </mx:columns>
      </mx:DataGrid>

      </mx:AddChild>
      </mx:State>
      </mx:states>

      public var data:DataObject

      public function setAxis(d: data:DataObject):void {
      data = d;
      // check function array to see if it needs to be displayed
      if (data.getFunctions().length > 0) {
      applyFunc.selected=true;
      changeState();
      }
      else {
      applyFunc.selected=false;
      }
      trace(" data func NUM: ",data.functions.length); // prints the number of functions

      }

      public function changeState():void {
      if (applyFunc.selected) this.currentState='functionView';
      else this.currentState='';
      }


      So why does my DataGrid 'funcTable' still show up as null during debugging after I have called changeState() and more importantly how to I get the function DataGrid object to show the functions of the new DataObject?