如何让alternItemColors在spark MX DataGrid ItemRenderer中正常工作?

时间:2011-05-02 23:27:15

标签: flex flex4

我正在尝试为自定义MXDataGridItemRenderer设置alternatingItemColors,似乎没有任何效果。我已经尝试了设置我能想到的属性的每个组合,从应用程序到dataGrid,再到渲染器,autoDrawBackground的每个组合都设置为true或false而没有运气。最后,我希望使用自定义itemRenderer,它在标签后面有一组半透明基元,使用alternatingItemColors使行更容易阅读,但保持自定义渲染器的样式不变。任何建议将不胜感激。

谢谢, 〜尼

好吧,我不习惯格式化,发布回复等等,但我只是想附加原帖,希望对每个人都有效......

再次,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>

这是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>

1 个答案:

答案 0 :(得分:1)

这可能有点晚了,因为这是一个三个月的帖子,但是如果你还在寻找答案......看起来这可能是问题所在:

alternatingItemColors="#FFFFFF, #000000"

应该是:

alternatingItemColors="[#FFFFFF, #000000]"