2012-07-31 50 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; 
    }  
}