2 Replies Latest reply on Aug 22, 2006 6:23 AM by peterent

    Nest a DataGrid within another DataGrid using ActionScript?

    allnighter
      I am running into an interesting issue. I am trying to nest a DataGrid in a column of another DataGrid by setting the ItemRenderer property. But I am hitting a well that might be due to the way setting itemRenderers are done in ActionScript or just my ignorance.

      Here's the issue -

      When I set the itemRenderer property of for a grid column, it has to be set as follows -

      col.itemRenderer = new ClassFactory(DataGrid);

      But if I do that, since I am dealing with the class and not the instance of the DataGrid, how do I set the dataProvider, columns and other properties for my nested grid? I know we can do this in MXML but how to achieve the same in ActionScript?

      Thank you.
        • 1. Re: Nest a DataGrid within another DataGrid using ActionScript?
          allnighter Level 1
          May be if I have a custom grid class and have it implment the IFactory interface, would that work? Even then how do I set the columns, dataProvider etc. ?

          Thank you.
          • 2. Re: Nest a DataGrid within another DataGrid using ActionScript?
            peterent Level 2
            A very interesting question. I should try this myself at some point. If you were using a drop-in itemRenderer, it might look like this:

            <mx:DataGridColumn dataField="gridData" ... >
            <mx:itemRenderer>
            <mx:Component>
            <mx:DataGrid dataProvider="{data.gridData}" width="100%" height="100%" ...>
            ...
            </mx:DataGrid>
            </mx:Component>
            </mx:itemRenderer>
            </mx:DataGridColumn>

            In ActionScript, this might work, but you would need to extend DataGrid or use a container wrapper.

            class DataGridItemRenderer extends DataGrid {
            override public function set data(value:Object):void {
            super.data = value;
            dataProvider = data. gridData;
            }
            ...
            }

            This should do it.