Flex DataGrid标题列分隔符

时间:2015-04-27 19:25:14

标签: actionscript-3 flex datagrid flash-builder

我正在使用mx:DataGrid(在Halo主题中),我在标题列分隔符/垂直网格线颜色方面遇到了一些问题。有谁知道如何自定义/更改线条颜色?

谢谢!

- 萌

1 个答案:

答案 0 :(得分:1)

Datagrid有两种样式horizontalSeparatorSkinverticalSeparatorSkin样式,您可以覆盖它们。看来你需要覆盖后者。

public class VerticalSeparatorSkin extends ProgrammaticSkin
    {
        public function VerticalSeparatorSkin()
        {
            super();
        }

        override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
        {
            // draw a line at the bottom of the rectangle defined by
            // unscaledWidth and unscaledHeight
            var g:Graphics = this.graphics;
            g.clear();
            g.lineStyle(3, 0x00FF00); // change thickness / color here
            g.moveTo(0,unscaledWidth);
            g.lineTo(unscaledWidth, unscaledHeight);
        }
    }

现在你可以把这个类写成:

public class MyCustomGrid extends DataGrid
    {
        public function MyCustomGrid()
        {
            super();
        }

        override protected function drawVerticalLine(s:Sprite, colIndex:int, color:uint, x:Number):void
        {
            var contentHolder:ListBaseContentHolder = s.parent.parent as ListBaseContentHolder;
            var g:Graphics = s.graphics;
            g.lineStyle(3, color); // change the thickness here
            g.moveTo(x, 0);
            g.lineTo(x, contentHolder.height);
        }
    }

这应该做的工作。另一种选择是自定义数据网格。

DataGrid

然后可以使用它代替常规{{1}}。