How do you get alternatingItemColors to work properly in spark MXDataGridItemRenderer?
I'm trying to set the alternatingItemColors for a custom MXDataGridItemRenderer and nothing seems to work. I've tried every combination of setting the 开发者_JAVA百科property that I can think of, from the application, to the dataGrid, to the renderer, with every combination of autoDrawBackground set to true or false with no luck. Ultimately, I'm looking to use the custom itemRenderer, which has a set of semi-transparent primitives behind the label, with the alternatingItemColors to make the rows easier to read, but keep the style of the custom renderer intact. Any suggestions would be appreciated.
Thanks, ~Benny
Okay, I'm not used to the formatting, and posting replies and so forth, but I'm just going to append the original post, hopefully that works okay for everyone...
So, again, the ItemRenderer:
<s:MXDataGridItemRenderer
xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
focusEnabled="true"
minWidth="25" minHeight="25"
>
<!--- States -->
<s:states>
<s:State name="normal" />
<s:State name="hovered" />
<s:State name="selected"/>
<s:State name="disabled" />
</s:states>
<!--- TransparencyGroup_(=(-->
<s:Group
top="0" right="0" bottom="0" left="0"
alpha="0.7"
>
<!--- BaseRectOuter -->
<s:Rect
radiusX="5" radiusY="5"
top="0" right="0" bottom="0" left="0"
>
<s:fill>
<s:LinearGradient rotation="90">
<s:GradientEntry
color="0x333333"
/>
<s:GradientEntry
color="0x121212"
/>
</s:LinearGradient>
</s:fill>
</s:Rect>
<!--- BaseRectInner -->
<s:Rect
radiusX="5" radiusY="5"
top="1" right="0" bottom="1" left="0"
>
<s:fill>
<s:LinearGradient rotation="90">
<s:GradientEntry
color="0x222222"
/>
<s:GradientEntry
color="0x444444"
/>
</s:LinearGradient>
</s:fill>
</s:Rect>
<!--- InnerRect -->
<s:Rect
radiusX="4" radiusY="4"
top="2" right="2" bottom="2" left="2"
>
<s:fill>
<s:LinearGradient rotation="90">
<s:GradientEntry
color="0x000"
color.hovered="0x105562"
/>
<s:GradientEntry
color="0x333333"
color.selected="0x105562"
/>
</s:LinearGradient>
</s:fill>
</s:Rect>
<!--- InnerStroke -->
<s:Rect
radiusX="4" radiusY="4"
top="1" right="2" bottom="1" left="2"
>
<s:stroke>
<s:LinearGradientStroke rotation="90" weight="1">
<s:GradientEntry
color="0x000"
color.selected="0xCCCDDD"
/>
<s:GradientEntry
color="0x666666"
color.selected="0x000"
alpha="0.6"
/>
</s:LinearGradientStroke>
</s:stroke>
</s:Rect>
</s:Group>
<!--- _)=)-->
<!--- Label -->
<s:Label
id="lblData"
text="{dataGridListData.label}"
fontSize="12"
color="0xFFFFFC"
height="12"
left="12" right="12"
trackingLeft="20%"
verticalCenter="0"
mouseEnabled="false"
/>
</s:MXDataGridItemRenderer>
And here's the DataGrid:
<mx:DataGrid
xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
rowHeight="30"
headerHeight="30"
fontFamily="Times New Roman"
fontSize="14"
textAlign="center"
paddingTop="2" paddingRight="0"
paddingBottom="2" paddingLeft="0"
verticalScrollPolicy="auto"
borderVisible="false"
dropShadowVisible="false"
rollOverColor="#01292B"
selectionColor="#000000"
chromeColor="#1D3A40"
alternatingItemColors="#FFFFFF, #000000"
>
<fx:Script>
<![CDATA[
import b_renderers.DGR_NameCol_01;
import b_renderers.DGItemRenderer_02;
import b_renderers.HeaderRenderer_01;
]]>
</fx:Script>
<mx:columns>
<mx:DataGridColumn
itemRenderer="b_renderers.DGR_NameCol_01"
headerRenderer="b_renderers.HeaderRenderer_01"
headerText="(|_ Name _|)"
dataField="name"
sortable="false"
width="285"
/>
<mx:DataGridColumn
itemRenderer="b_renderers.DGItemRenderer_02"
headerRenderer="b_renderers.HeaderRenderer_01"
headerText="Time"
dataField="time"
width="65"
/>
<mx:DataGridColumn
itemRenderer="b_renderers.DGItemRenderer_02"
headerRenderer="b_renderers.HeaderRenderer_01"
headerText="-| Genre |-"
dataField="genre"
width="165"
/>
</mx:columns>
</mx:DataGrid>
This may be a bit late, since this is a three month old post, but if you are still looking for an answer...it looks like this might be the problem:
alternatingItemColors="#FFFFFF, #000000"
should be:
alternatingItemColors="[#FFFFFF, #000000]"
精彩评论