为AdvancedDataGrid设置备用颜色 - 一个用于父节点,另一个用于子节点 [英] Set alternate color for AdvancedDataGrid - one for parent node and other for child nodes
问题描述
请参阅:为Adobe Flex中的datagrid行设置背景颜色
我有一个高级数据网格作为数据源HierarchicalData。为此,我必须为父节点和其他节点设置备用背景色。
< mx: AdvancedDataGrid id =electionGridalternatingItemColors =[#449933,#994433]width =100%height =70%folderOpenIcon ={null}folderClosedIcon ={null}defaultLeafIcon ={null}可编辑= 真 >
< mx:dataProvider>
< / mx:dataProvider>
< mx:columns>
< mx:AdvancedDataGridColumn dataField =productheaderText =Producteditable =false/>
< mx:AdvancedDataGridColumn dataField =accountIDheaderText =Account IDeditable =false/>
< mx:AdvancedDataGridColumn dataField =accountDescriptionheaderText =账户描述editable =false/>
< mx:AdvancedDataGridColumn dataField =electionStatusheaderText =Election Statuseditable =true/>
< mx:AdvancedDataGridColumn dataField =electionsQuantityheaderText =Elected Quantity/>
< mx:AdvancedDataGridColumn dataField =percentelectionDetailsheaderText =Election%Details/>
< mx:AdvancedDataGridColumn dataField =commentsheaderText =Comments/>
< / mx:columns>
< / mx:AdvancedDataGrid>
我已经使用了alternatingItemColors风格,但不能按预期工作。
alternatingItemColors =[#449933,#994433]
我需要为父节点和子节点设置备用颜色。
结构化数据:
< mx:ArrayCollection id =electionSummary>
electionquantity =0percentelectionDetails =0>
< model:electionOptions>
< mx:ArrayCollection id =optionData1>
< model:Options electionStatus =Not submitted/>
< / mx:ArrayCollection>
< / model:electionOptions>
< / model:选举>
$ b $ lt; model:选择产品=全球PBaccountID =10473834accountDescription =基金1.2帐户题名=250000
electionquantity =0percentelectionDetails =0 >
< model:electionOptions>
< mx:ArrayCollection id =optionData2>
< model:Options electionStatus =Not submitted/>
< / mx:ArrayCollection>
< / model:electionOptions>
< / model:选举>
$ b $ lt; model:选择产品=全球PBaccountID =10473834accountDescription =基金1.2帐户题名=250000
electionquantity =0percentelectionDetails =0 >
< model:electionOptions>
< mx:ArrayCollection id =optionData3>
< model:Options electionStatus =Not submitted/>
< / mx:ArrayCollection>
< / model:electionOptions>
< / model:选举>
< / mx:ArrayCollection>
也可以通过覆盖datagrid中的drawRowBackground函数来完成。
请参阅: http://flexpearls.blogspot .com / 2008/02 / row-background-color-in.html
有没有简单的方法来完成替代颜色设置为使用的一个hiearchical数据在DataGrid中。
总之,没有。据我所知,没有一种简单的方式来为 AdvancedDataGrid
。
最接近你想要的就是 depthColors
属性,但会将该深度处的所有行设置为一种颜色,而不是交替排列。
It seems there are various ways to set the background color for a datagrid.
See: How to dynamically change background colour of datagrid row?
See: Setting background color for datagrid row in Adobe Flex
I have a advanced datagrid with HierarchicalData as the datasource. For this, i have to set alternate background color one for the parent node and other for the child nodes.
<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>
I have used alternatingItemColors style but it is not working as expected.
alternatingItemColors="[#449933, #994433]"
I need to set alternate color for parent node and child node.
Hiearchical Data:
<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>
It can also accomplished by overriding drawRowBackground function in datagrid.
See : http://flexpearls.blogspot.com/2008/02/row-background-color-in.html
Is there a simple way to accomplish alternate color setting for a hiearchical data used in DataGrid.
In short, no. To my knowledge there's no "simple" way to set different alternating row colors for an AdvancedDataGrid
based on depth (parent/child).
The closest thing to what you want is the depthColors
property but that will set all rows at that depth to a color, not alternating rows.
这篇关于为AdvancedDataGrid设置备用颜色 - 一个用于父节点,另一个用于子节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!