2 Replies Latest reply on Jul 3, 2006 12:36 PM by inlineblue

    datagrid using php (xml)

    henk_jan
      Hello,
      I followed some tutorials about filling up a datagrid using php (or asp) and the HTTPService.
      I use this technique for sometime with flash but my generated xml file is somewhat diferent. I use attributes to identify my database fieldnames. Like so:
      <?xml version="1.0" encoding="ISO-8859-1" ?>
      - <recordset>
      - <record>
      <cel field="usernr">1234</cel>
      <cel field="firstname">albert</cel>
      <cel field="lastname">Jansen</cel>
      </record>
      <record>
      <cel field="usernr">456</cel>
      <cel field="firstname">Jan</cel>
      <cel field="lastname">Pietersen</cel>
      </record>
      </recordset>

      Does anyone know how to retrieve this data?

      I tried something like this but that didn't work:

      ....
      <mx:DataGrid x="10" y="10" id="dgUsers"
      dataProvider="{userRequest.lastResult.recordset.record}">
      <mx:columns>
      <mx:DataGridColumn headerText="Salarisnr" dataField="cel[0]"/>
      </mx:columns>
      </mx:DataGrid>
      ....
        • 1. Re: datagrid using php (xml)
          Flex harUI Adobe Employee
          You will need to use labelFunctions. Set the dataField to the name of the field then add a label function that does the right E4X to get the data. We can help with the E4X if needed.
          • 2. Re: datagrid using php (xml)
            inlineblue Level 1
            The "dataField" property can't accept an indexed value like "cel[0]". You'll have to use the grid's labelFunction instead:

            <mx:DataGrid x="10" y="10" id="dgUsers"
            dataProvider="{userRequest.lastResult.recordset.record}">
            <mx:columns>
            <mx:DataGridColumn headerText="Salarisnr" labelFunction="labelFunc"/>
            </mx:columns>
            </mx:DataGrid>

            private function labelFunc(item: Object, column: DataGridColumn): String
            {
            if (column.headerText == "Salarisnr")
            return item.cel[0];
            //etc...
            }