2010-06-16 67 views
1

我想通過編輯headerColor樣式來更改datagrid標題的顏色。除了headerColor之外,我可以更改字體大小,字體系列等。有人會幫助我嗎?非常感謝。Flex datagrid headerColor風格不起作用

我的代碼

MXML

<mx:DataGrid id="dataGrid" creationComplete="dataGrid_creationCompleteHandler(event)" dataProvider="{cityinfoResult3.lastResult}"> 
<mx:columns> 
<mx:DataGridColumn headerText="Detail" dataField="detail"/> 
<mx:DataGridColumn headerText="Name" dataField="name"/> 
</mx:columns> 
</mx:DataGrid> 

樣式

#dataGrid{ 
headerColors: #ff6600; //everything works except this one. The color can't be     
          //changed? 
rollOverColor: #33ccff; 
textRollOverColor: #ffffff; 
iconColor: #ff0000; 
fontFamily: Arial; 
fontSize:12; 
dropShadowEnabled: true; 
alternatingItemColors: #330099, #0000cc; 
color: #ffffff; 
borderColor: #ffffff; 
} 

回答

1

headerColors需要爲了繪製漸變的2項的陣列。如果你想要一個純色的,我敢打賭,一些likethis會的工作:

headerColors: #ff6600, #ff6600 ; 
+0

泰再次幫助我。我試過你的代碼,但它給了我風格的語法錯誤。我使用了「headerColors:#ff6600,#ffffff;」錯誤消失了,但顏色不能改變...... :( – FlyingCat 2010-06-16 02:51:31

+0

)如果你使用Halo主題,headerColors只支持Flex 4,所以你可能需要添加編譯器參數-theme = $ {flexlib } /themes/Halo/halo.swc。一旦我做到了,顏色出現了。 – JeffryHouser 2010-06-16 12:34:36

+0

hm ...我相信我必須像下面那樣添加它.. -locale en_US -theme = $ {flexlib}/themes/Halo/halo.swc。編譯器給了我很多警告,說:「風格」borderColor「只支持類型'spark.component.panel'與主題spark」,並且不能呈現我的應用程序.... – FlyingCat 2010-06-16 14:31:59

1

在Flex的CSS,你不想在你的價值觀括號[](雖然你想他們,如果你這樣做在直接的ActionScript中)。

這應該做的伎倆:

headerColors: #ff6600, #ff6600;

+0

Ty ..但我已經嘗試過我......但沒有運氣。 – FlyingCat 2010-06-16 14:32:46

0

試試這個

dataGrid.setStyle("headerColors", ["red", "blue"]); 
1

的MX DataGrid中,創建一個新的皮膚MXML(S:SparkSkin)和複製mx.skins。 spark.DataGridHeaderBackgroundSkin代碼放入您的自定義外觀類中。

找到下面的代碼片段,並用您選擇的顏色替換值。

<!-- layer 2: fill --> 
<s:Rect left="0" right="0" top="0" bottom="0"> 
    <s:fill> 
     <s:LinearGradient rotation="90"> 
      <s:GradientEntry color="0xFFFFFF" 
          alpha="0.85" /> 
      <s:GradientEntry color="0xD8D8D8" 
          alpha="0.85" /> 
     </s:LinearGradient> 
    </s:fill> 
</s:Rect> 

在你的DataGrid組件,標題背景皮膚指向您的自定義皮膚:

<mx:DataGrid id="dataGrid" headerBackgroundSkin="assets.skins.CustomDataGridSkin">