4 Replies Latest reply on Aug 27, 2007 7:38 AM by Handycam

    DataGrid dataField question

    Handycam Level 1
      I'm a bit embarassed since this is simple but I've forgotten how to display "unlabelled" data in a datagrid.

      I've combined my data output into a 2-level array, _megaArray:

      private function catTest() : void {
      var _arr:Array = _chosen0.concat(_chosen1,_chosen2.source,_chosen3.source...,_chosen10);
      for (var i:int = 0; i<_arr.length; i++){
      var _a:String = _arr .@qty;
      var _b:String = _arr
      var _c:String = _arr .@ln2;
      var _s:String = _a + _b +_c;
      trace("mega array = "+_megaArray);

      _megaArray contains stuff like "1.25,cups,dried cannellini,.5,cups,chopped onions,.5,cups,chopped leeks,.5,cups,chopped celery"

      I've wrapped this in an ArrayCollection:

      private var _dgData : ArrayCollection = new ArrayCollection(_megaArray);

      And I've created a DataGrid to display this:

      <mx:DataGrid id="myDG" width="100%" dataProvider="{_dgData}" >
      <mx:DataGridColumn dataField="qty" width="35"/>
      <mx:DataGridColumn dataField="units" width="40" />
      <mx:DataGridColumn dataField="desc" />

      But it's empty, and I'm sure it's because it doesn't know from "qty" "units" or "desc". I know how to display more structured data (e.g. an XML file) but in this case I need to keep the array as it is. I just want the first data element in the first column, the second in the second and the third in the third.

      But I've forgotten how to do this...