在Flex中的AdvancedDataGrid选定行中显示边框颜色

时间:2016-07-21 12:10:06

标签: actionscript-3 flex datagrid flex4.5 advanceddatagrid

如何在Flex 4.6中的AdvancedDataGrid中显示所选行的borderColor。您可以看到以下图像供您参考。

enter image description here

1 个答案:

答案 0 :(得分:2)

选定的行位于通过专用AdvancedDataGrid实现的Sprite中,用作绘图画布。要在选择标记中创建边框,您需要根据AdvancedDataGrid创建自定义类并覆盖受保护的方法drawSelectionIndicator

以下示例应生成1px宽红色边框的选择标记:

public class GridWithBorderedSelectionMarker extends AdvancedDataGrid {
    override protected function drawSelectionIndicator(
            indicator:Sprite, x:Number, y:Number, width:Number,
            height:Number, color:uint,
            itemRenderer:IListItemRenderer):void {
        if (isRowSelectionMode()) {
            width = unscaledWidth - viewMetrics.left - viewMetrics.right;
        }
        var borderColor:uint = 0xff0000;
        var g:Graphics = Sprite(indicator).graphics;
        g.clear();
        g.beginFill(borderColor);
        g.drawRect(0, 0, width, height);
        g.beginFill(color);
        g.drawRect(1, 1, width - 2, height - 2);
        g.endFill();
        indicator.x = x;
        indicator.y = y;
    }
}