开发者

ItemRenderer for TreeColumn on AdvancedDataGrid in Flex

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 ima开发者_C百科ge)

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

titleColumnRenderer:

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


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);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜