2012-07-31 51 views
1

我在我的flex应用程序中使用了mx:DataGrid组件。我示出的网格是这样的:使SelectionColor在mx中透明:datagrid

enter image description here

我想选择的蓝颜色改变为透明的。我正在使用以下代码:

<mx:DataGrid id="dg" dataProvider="{arrDg}" width="100%" height="100%" 
    draggableColumns="false" rowCount="{arrDg.length}" click="dgClickHandler(event)" 
    variableRowHeight="true" resizableColumns="false" sortableColumns="false" 
    selectionColor="#00000000" verticalScrollPolicy="off"> 

但是,这会将颜色更改为黑色而不是透明。

请帮忙。

回答

1

[编辑[

哎呀,没注意到你穿那种颜色有8个零。 Flash不支持RGBA(或具有alpha /透明度的颜色值)。

[编辑完]

如果你不希望任何亮点可言要在选择显示,尝试DataGrid设置(MX)的selectable属性false。看起来你有一个点击处理程序,关闭选择可能会阻止你的点击处理程序做它的工作:(

如果你确实想要某种选择指标,但是说,想要修改alpha(透明度)选择颜色,该样式设置不存在(即:没有“selectionAlpha”样式)您将不得不创建一个自定义数据网格类来做到这一点

+0

设置“选择”虚假的伎俩,我也去掉了点击处理程序。 – mudit 2012-07-31 12:14:56

0

如果您需要mx:DataGrid是可选的,但也可以希望选择颜色不会影响您的单元格/行的颜色,您可以使用此方法:

扩展DataGrid覆盖功能drawSelectionIndicator和le AVE功能空的内容(也可能有兴趣在重写drawHighlightIndicator功能)

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

    override protected function drawSelectionIndicator(indicator:Sprite, x:Number, y:Number, w:Number, h:Number, color:uint, itemRenderer:IListItemRenderer):void 
    { 
     //If you want a rectangle arround the selected row use call this method 
     //Rectangle(indicator,x,y,0xFF9900, 2,h) ; 
    } 

    override protected function drawHighlightIndicator(indicator:Sprite, x:Number, y:Number, w:Number, h:Number, color:uint, itemRenderer:IListItemRenderer):void 
    { 
     Rectangle(indicator,x,y,highlight, 2,h) ; 
    } 

    private function Rectangle(indicator:Sprite, xx:int, yy:int,colorBorde:uint,grosor:int, h:int):void 
    { 
     var g:Graphics ; 
     var w:int ; 

     w = this.width - this.verticalScrollBar.width-1 ; 

     g = Sprite(indicator).graphics; 
     g.clear(); 
     g.lineStyle(grosor,colorBorde) ; 
     g.drawRect(0,1,w-grosor,h-grosor) ; 

     indicator.x = xx; 
     indicator.y = yy; 
    }  
}