首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >设置AdvancedDataGrid的替代颜色-一个用于父节点,另一个用于子节点

设置AdvancedDataGrid的替代颜色-一个用于父节点,另一个用于子节点
EN

Stack Overflow用户
提问于 2011-04-06 21:02:41
回答 1查看 2.3K关注 0票数 3

似乎有多种方法可以设置数据网格的背景色。

请参阅:How to dynamically change background colour of datagrid row?

请参阅:Setting background color for datagrid row in Adobe Flex

我有一个以HierarchicalData作为数据源的高级数据网格。为此,我必须为父节点和子节点设置备用背景色。

代码语言:javascript
复制
<mx:AdvancedDataGrid id="electionGrid" alternatingItemColors="[#449933, #994433]" width="100%" height="70%" folderOpenIcon="{null}" folderClosedIcon="{null}" defaultLeafIcon="{null}" editable="true">
        <mx:dataProvider>
            <mx:HierarchicalData source="{electionSummary}" childrenField="electionOptions"/>
        </mx:dataProvider>
        <mx:columns>
            <mx:AdvancedDataGridColumn dataField="product" headerText="Product" editable="false"/>              
            <mx:AdvancedDataGridColumn dataField="accountID" headerText="Account ID" editable="false"/>
            <mx:AdvancedDataGridColumn dataField="accountDescription" headerText="Account Description" editable="false"/>
            <mx:AdvancedDataGridColumn dataField="electionOption" headerText="Election Options" editable="false"/>
            <mx:AdvancedDataGridColumn dataField="electionStatus" headerText="Election Status" editable="true"/>
            <mx:AdvancedDataGridColumn dataField="entitledQuantity" headerText="Entitled Quantity"/> 
            <mx:AdvancedDataGridColumn dataField="electedQuantity" headerText="Elected Quantity"/>
            <mx:AdvancedDataGridColumn dataField="percentelectionDetails" headerText="Election %Details"/>
            <mx:AdvancedDataGridColumn dataField="comments" headerText="Comments"/>
        </mx:columns>        
    </mx:AdvancedDataGrid>

我使用了alternatingItemColors风格,但它并不像预期的那样工作。

代码语言:javascript
复制
alternatingItemColors="[#449933, #994433]"

我需要为父节点和子节点设置替代颜色。

分层数据:

代码语言:javascript
复制
<mx:ArrayCollection id="electionSummary">
    <model:Elections product="Global PB" accountID="10473834" accountDescription="Fund 1.2 Account" entitledQuantity="250000"
                        electedQuantity="0" percentelectionDetails="0">    
        <model:electionOptions>
            <mx:ArrayCollection id="optionData1">
                <model:Options electionStatus="Not Submitted"/>
            </mx:ArrayCollection>
        </model:electionOptions>
    </model:Elections>

    <model:Elections product="Global PB" accountID="10473834" accountDescription="Fund 1.2 Account" entitledQuantity="250000"
                        electedQuantity="0" percentelectionDetails="0">    
        <model:electionOptions>
            <mx:ArrayCollection id="optionData2">
                <model:Options electionStatus="Not Submitted"/>
            </mx:ArrayCollection>
        </model:electionOptions>
    </model:Elections>

    <model:Elections product="Global PB" accountID="10473834" accountDescription="Fund 1.2 Account" entitledQuantity="250000"
                        electedQuantity="0" percentelectionDetails="0">    
        <model:electionOptions>
            <mx:ArrayCollection id="optionData3">
                <model:Options electionStatus="Not Submitted"/>
            </mx:ArrayCollection>
        </model:electionOptions>
    </model:Elections>
</mx:ArrayCollection>

它也可以通过覆盖datagrid中的drawRowBackground函数来实现。

请参阅:http://flexpearls.blogspot.com/2008/02/row-background-color-in.html

有没有一种简单的方法来实现DataGrid中使用的历史数据的交替颜色设置?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-04-06 23:13:20

简而言之,不是。据我所知,没有一种“简单”的方法可以根据深度(父/子)为AdvancedDataGrid设置不同的交替行颜色。

最接近您需要的是depthColors属性,但它会将该深度的所有行设置为一种颜色,而不是交替的行。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5566786

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档