2 Replies Latest reply on Apr 21, 2008 10:57 AM by dan19460

    Data Grid Provider, XML attributes

      Hi all,
      I'm trying to populate a dataGrid component with following XML sample:
      <column name="dataGrid Header 1">Test Data 1.1</column>
      <column name="dataGrid Header 2">Test Data 1.2</column>
      <column name="dataGrid Header 1">Test Data 2.1</column>
      <column name="dataGrid Header 2">Test Data 2.2</column>
      I assume that it should be something like below, but I can't find a way to make it work:
      var dataXML:XMLList = null;
      function resultHandle(event) {
      dataXML = event.result.root;
      <mx:DataGrid dataProvider="{dataXML.row}">
      <mx:DataGridColumn headerText="column[0].@name" dataField="column.(@name=='dataGrid Header 1')"/>
      <mx:DataGridColumn headerText="column[1].@name" dataField="column.(@name=='dataGrid Header 2')"/>


      <mx:DataGrid dataProvider="{dataXML.row}">
      <mx:DataGridColumn headerText="{dataXML.row[0].column[0].@name}" dataField="{column[0]}"/>
      <mx:DataGridColumn headerText="{dataXML.row[0].column[1].@name}" dataField="{column[1]}"/>

      If anyone has any suggestions/comments, I would much appreciate it.
        • 1. Re: Data Grid Provider, XML attributes
          Hi there,

          I am looking for a solution like yours, but it seems that flex does not like much the XML attributes nor xpath syntax.

          As a workaround, I would modify your source XML to be
          <dataGridHeader1>Test Data 1.1</dataGridHeader1>
          <dataGridHeader2>Test Data 1.2</dataGridHeader2>

          This way, you can take the appropriate value by describing
          <mx:DataGridColumn headerText="{dataXML.column.dataGridHeader1}" dataField="{column[0]}"/>
          <mx:DataGridColumn headerText="{dataXML.column.dataGridHeader2}" dataField="{column[1]}"/>

          Hope it helps. Let me know if you find the REAL solution to read attributes and Xpath,

          Best regards,
          • 2. Re: Data Grid Provider, XML attributes
            Try re-working your solution to assign the event.result to the XMLList instead of event.result.root. The "root" node is implied. If you assign event.result.row to the XMLList variable you will have a collection of rows.

            xmlData = event.result.row;
            trace(xmlData); // you should see an xml fragment containing just "row" objects.

            Hope this helps.