我正在尝试通过编辑headerColor样式来更改数据网格标题颜色。除了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;
}
答案 0 :(得分:1)
headerColors需要一个包含2个项目的数组才能绘制渐变。如果你想要一个纯色,我敢打赌它会起作用:
headerColors: #ff6600, #ff6600 ;
答案 1 :(得分:1)
在Flex的CSS中,你不希望你的值附近有[]括号(尽管如果你在直接的ActionScript中这样做, 会想要它们)。
这应该可以解决问题:
headerColors: #ff6600, #ff6600;
答案 2 :(得分: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">
答案 3 :(得分:0)
试试这个
dataGrid.setStyle("headerColors", ["red", "blue"]);