1 Reply Latest reply on Nov 19, 2007 6:15 AM by ntsiii

    Complex E4X query dataFields for DataGrid

      Hi all, still fighting with DataGrids. For today, lets assume I have some XML like this:

      var testData : XML =
      <category name="Category 1" id="1">
      <item year="2007">300</item><item year="2008">400</item><item year="2009">500</item>
      <category name="Category 2" id="2">
      <item year="2007">600</item><item year="2008">500</item><item year="2009">300</item>

      And later, I define my DataGrid:

      <mx:DataGrid id="test" editable="true" height="100%" width="100%" dataProvider="{testData.category}" textAlign="center" alternatingItemColors="[#FFFFFF,#EAEAEA]" draggableColumns="false" >
      <mx:DataGridColumn headerText="Category" dataField="@name" />
      <mx:DataGridColumn headerText="2007" dataField="item.(@year==2007)" />

      I eventually want to define the columns dynamically, which I can do. But first, I need to figure out how to populate the columns. Why doesn't this E4X item.(@year==2007) query work properly? I can do Alert.show( testData.category.item.(@year==2007) ) in a script portion of the mxml, and it returns the fields that are expected.