1 Reply Latest reply on Feb 15, 2007 3:48 PM by JimBischoff

    Traversing external XML in datagrid

    JTMcGarvey
      REPOST IN CORRECT SECTION:

      Hi,
      I am trying to traverse XML received via HTTPService in a datagrid. The value I have defined for DataGridColumn "Player" (player.firstname) returns nothing. What is the correct syntax?

      <entry>
      <name>TEST</name>
      <player>
      <firstname>Grant</firstname>
      </player>
      </entry>

      <mx:Panel x="10" y="10" width="610" height="464" layout="absolute" title="CrunchTime Leaderboard">
      <mx:DataGrid id="leaders" x="0" y="0" width="574" height="225" dataProvider="{xmldata.lastResult.leaderboard.game.entries.entry}">
      <mx:columns>
      <mx:DataGridColumn headerText="Screen Name" dataField="name"/>
      <mx:DataGridColumn headerText="Player" dataField="player.firstname" width="120"/>
      </mx:columns>
      </mx:DataGrid>

      </mx:Panel>

      Thank you!
        • 1. Re: Traversing external XML in datagrid
          JimBischoff
          You can use the labelFunction property of the mx:DataGridColumn for this. Create a function like:
          <mx:Script>
          <![CDATA[
          protected function getPlayerName(row:Object, column:DataGridColumn):String {
          return row.player.firstname + " " + row.player.lastname;
          }
          ]]>
          </mx:Script>

          Then the column reference looks like:
          <mx:DataGridColumn headerText="Player" labelFunction="getPlayerName" width="120"/>