4 Replies Latest reply on Oct 3, 2008 9:55 AM by SMannava

    Advanced Datagrid multi level rendering

    SMannava
      Hi,

      I am very new to Advanced datagrid and can't able to figure out how to render a collection I am getting.
      The data is look like the Hirarchy bellow.

      ----games:ListCollectionView
      ------------ gameTurns: ListCollectionView
      ---------------------gameOrders:ListCollectionView

      What I am trying here is displaying them in Hirarchy.

      The resultHandler i have is like this.

      private function getGameHistoryResultHandler(e:ResultEvent):void
      {
      //Alert.show("getGameHistoryResultHandler (expected GameHistoryDto) : " + e.result);
      if (! e.result is GameHistoryDto)
      {
      Alert.show("Invalid result (expected GameHistoryDto) : " + e.result);
      return;
      }

      // extract game history
      var gameHistoryDto:GameHistoryDto = e.result as GameHistoryDto;

      /**
      gameHistoryData = new HierarchicalData(gameHistoryDto.games);


      gameHistoryData.childrenField = "gameTurns";


      gameHistoryADG.dataProvider = gameHistoryData;
      */
      //////////////////////////////////

      var g:Grouping = new Grouping();
      g.fields = [new GroupingField("name")];

      var gc:GroupingCollection = new GroupingCollection();
      gc.source = gameHistoryDto.games;//new ArrayCollection(planets);
      //gc.grouping = g;
      //
      gc.childrenField = "gameTurns";

      //gc.childrenField = "gameOrders";
      ////gc.childrenField = "gameBids";
      //gc.childrenField = "gamePrizes";
      gc.refresh();


      gameHistoryADG.dataProvider = gc;
      //gameHistory.dataProvider = e.result;


      }

      //////////////////////////////////////////////
      The MXML is

      <mx:AdvancedDataGrid id="gameHistoryADG" dataProvider="{new HierarchicalData(gameHistoryData)}"
      variableRowHeight="true" width="700" height="500">
      <mx:columns>
      <mx:AdvancedDataGridColumn dataField="name" headerText="Name" width="250"/>
      <mx:AdvancedDataGridColumn dataField="duration" headerText="Duration" />
      <mx:AdvancedDataGridColumn dataField="requiredPlayers" headerText="Required Players" />
      <mx:AdvancedDataGridColumn dataField="entranceFee" headerText="Entrance Fee" />
      </mx:columns>

      <mx:rendererProviders>
      <mx:AdvancedDataGridRendererProvider depth="2" columnIndex="1" columnSpan="0">
      <mx:renderer>
      <mx:Component>

      <mx:AdvancedDataGrid variableRowHeight="true">

      <mx:Script>

      <![CDATA[


      override public function set data(value:Object):void
      {

      dataProvider = value;

      }
      ]]>
      </mx:Script>

      <mx:columns>
      <mx:AdvancedDataGridColumn dataField="name" headerText="Name" />
      <mx:AdvancedDataGridColumn dataField="playerName" headerText="Player Name" />
      <!--
      <mx:AdvancedDataGridColumn dataField="gameType" headerText="Game Type"/>
      <mx:AdvancedDataGridColumn dataField="gameStatus" headerText="Game Status"/>
      <mx:AdvancedDataGridColumn dataField="turnState" headerText="Turn State"/>
      -->
      </mx:columns>

      <mx:rendererProviders>

      <mx:AdvancedDataGridRendererProvider depth="3" columnIndex="2" columnSpan="0">
      <mx:renderer>
      <mx:Component>

      <mx:AdvancedDataGrid xmlns="*" xmlns:mx=" http://www.adobe.com/2006/mxml">
      <mx:Script>
      <![CDATA[
      import mx.collections.GroupingCollection;

      public var gc:GroupingCollection = new GroupingCollection();

      override public function set data(value:Object):void
      {
      gc.source = value['gameOrders'];
      gc.refresh();
      dataProvider = gc;

      }
      ]]>
      </mx:Script>

      <mx:columns>
      <mx:AdvancedDataGridColumn dataField="name" headerText="Name" />
      <mx:AdvancedDataGridColumn dataField="tradeableID" headerText="Tradable ID" />
      <mx:AdvancedDataGridColumn dataField="volume" headerText="Volume" />
      <mx:AdvancedDataGridColumn dataField="priceOrdered" headerText="Order Price"/>
      <mx:AdvancedDataGridColumn dataField="priceExecuted" headerText="Executed Price"/>
      </mx:columns>

      </mx:AdvancedDataGrid>

      </mx:Component>
      </mx:renderer>
      </mx:AdvancedDataGridRendererProvider>


      </mx:rendererProviders>

      </mx:AdvancedDataGrid>

      </mx:Component>
      </mx:renderer>
      </mx:AdvancedDataGridRendererProvider>

      </mx:rendererProviders>




      </mx:AdvancedDataGrid>

      A quick help will be appriciated.,

      Thanks,
      Srinivas