如何让alternatingItemColors在spark MXDataGridItemRenderer中正常工作?

发布于 2024-11-05 04:03:20 字数 4919 浏览 2 评论 0原文

我正在尝试为自定义 MXDataGridItemRenderer 设置交替项目颜色,但似乎没有任何效果。我尝试了我能想到的设置属性的所有组合,从应用程序到 dataGrid,再到渲染器,将 autoDrawBackground 的每个组合设置为 true 或 false,但没有成功。最终,我希望使用自定义 itemRenderer,它在标签后面有一组半透明基元,并带有交替项颜色以使行更易于阅读,但保持自定义渲染器的样式不变。任何建议将不胜感激。

谢谢, 〜Benny

好吧,我不习惯格式设置和发布回复等,但我只是要附加原始帖子,希望这对每个人都适用......

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

这是数据网格:

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

I'm trying to set the alternatingItemColors for a custom MXDataGridItemRenderer and nothing seems to work. I've tried every combination of setting the 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>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

七禾 2024-11-12 04:03:20

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

alternatingItemColors="#FFFFFF, #000000"< /code>

应该是:

alternatingItemColors="[#FFFFFF, #000000]"

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]"

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文