views:

1037

answers:

1

Is it possible to use a renderer for for a treecolumn in an advanceddatagrid and still keep the hierarchal functionality? If I use a renderer provider I lose the the arrow for the tree dropdown. I want to keep the tree functionality and change the display of the column.(and not just the folder image)

<mx:AdvancedDataGridRendererProvider column="{titleCol}" depth="1"
        renderer="com.something.titleColumnRenderer"/>

titleColumnRenderer:

<mx:VBox width="100%" xmlns:mx="http://www.adobe.com/2006/mxml"&gt;
<mx:Label id="titleLabel" textAlign="center" text="sometext" width="100"/></mx:VBox>
+2  A: 

Here's what I did to accomplish this:

  1. Create a class that extends AdvancedDataGridGroupItemRenderer
  2. In the new class override updateDisplayList and do what you need to do
  3. Assign the new class to the groupItemRenderer property of the AdvancedDataGrid

Here's what your new class might look like

public class CustomGroupRenderer extends AdvancedDataGridGroupItemRenderer
{
    override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
    {
        super.updateDisplayList(unscaledWidth, unscaledHeight);

        var listData:AdvancedDataGridListData = listData as AdvancedDataGridListData;
        var advancedDataGrid:AdvancedDataGridDataGrid = listData.owner as AdvancedDataGrid;

        var cellBackgroundColor:uint = 0xFF0000;

        var g:Graphics = graphics;
        g.clear();

        if (!advancedDataGrid.isItemSelected(data) && !advancedDataGrid.isItemHighlighted(data))
        {
            g.beginFill(cellBackgroundColor);
            g.drawRect(0, 0, unscaledWidth, unscaledHeight);
            g.endFill();
        }
    }
}

And then assign this class to the groupItemRenderer property of the AdvancedDataGrid:

<mx:AdvancedDataGrid groupItemRenderer="com.whereever.CustomGroupRenderer"/>

Or, in ActionScript:

myAdvancedDataGrid.groupItemRenderer = new ClassFactory(com.whereever.CustomGroupRenderer);
Jeremy Mitchell
This is close to what i need but I not just trying to change the color. I would like to add an VBox to it and put some items in the VBox. I tried this and super.addChild but the made the app freeze. any ideas?
Barrest
Jeremy Mitchell