3 Replies Latest reply on Oct 19, 2007 11:57 AM by AaffordableWeb

    Problem combining XMLLists and Arrays

    Handycam Level 1
      I have an application populated with data from an XML file. The data is assigned to XMLLists.
      these lists are bound to data grids.

      The user of the app drags chosen items from this grid to a second grid. I have the second grid's data provider set to be a new ArrayCollection, "_chosenItems". I then do all sorts of functions on _chosenItems: add up quantities, check for existence of certain members, etc. using typical array loops and methods. Ok, great so far.

      Now, at the end, I need to combine several of these lists into 1 long list for a new data grid showing totals. So I use something like:
      _combinedArray = _chosenItems1.source.concat(_chosenItems2.source, _chosenItems3.source);
      _dataGridArray.source = _combinedArray;

      I'm sure there's a better way (suggestions welcome), but this actually works.

      However, I have some items that will be hard-coded into the app that need to be part of this final datagrid. I had been doing this as an Array ({qty: 5, color:red, size:med} , {qty: 3, color:pink, size:sm})

      But then the other data from the _chosenItems (which started as XML) is accessed via data.@qty, data,@color etc. and this array is not in @ format. So these rows do not appear in the data grid, which is of course in the format:
      <mx:DataGridColumn dataField="@qty" headerText="Amount" /> 

      That's where I'm stuck. Help!

      (I supposed I could define an XMLList just as easily as an arrayCollection, but then I can't combine it with the other _chosenItems array collections as explained above. You can't concat an XMLList to other arrays. So what do I do?)