ItemRenderer on the Treecolumn on AdvancedDataGrid in Flex

Is it possible to use the renderer for the tree columns in the advanced data grid and still maintain the hierarchical functionality? If I use the renderer provider, I lose the arrow of the tree drop-down list. I want to keep the tree function and change the display of the columns. (not just the folder image)

 renderer="com.something.titleColumnRenderer"/>

titleColumnRenderer:


The following is what I did to achieve this goal:

>Create a class that extends AdvancedDataGridGroupItemRenderer
>Rewrite updateDisplayList in the new class and execute what you need to do
>Assign the new class to the groupItemRenderer property of AdvancedDataGrid

This is how your new class looks like

public class CustomGroupRenderer extends AdvancedDataGridGroupItemRenderer< br />{
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();
}
}
}

Then assign this class to the groupItemRenderer property of AdvancedDataGrid:

Or, In ActionScript:

myAdvancedDataGrid.groupItemRenderer = new ClassFactory(com.whereever.CustomGroupRenderer);

Is it possible to The renderer is used for the tree columns in the advanced data grid and still maintain the hierarchical structure function? If I use the renderer provider, I lose the arrow of the tree drop-down list. I want to keep the tree function and change the display of the columns. (not just the folder image)

 renderer="com.something.titleColumnRenderer"/>

titleColumnRenderer:


The following is my goal to achieve this The work done:

>Create a class that extends AdvancedDataGridGroupItemRenderer
>Rewrite updateDisplayList in the new class and perform what you need to do
>Assign the new class to AdvancedDataGrid The groupItemRenderer property

This is how your new class looks 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 adv ancedDataGrid: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();
}
}
}

Then assign this class to the groupItemRenderer of AdvancedDataGrid Attributes:

Or, in ActionScript:

myAdvancedDataGrid.groupItemRenderer = new ClassFactory(com.whereever.CustomGroupRenderer);

Leave a Comment

Your email address will not be published.