我可以使用Advanced Datagrid制作像应用程序一样的轴吗?

时间:2010-09-08 15:39:58

标签: flex advanceddatagrid

我想捕获标题点击事件,点击后,我想通过在每个级别动态添加AdvancedDatgridColumnGroup来拆分列。这样可行吗? Atleast帮助我捕获标题点击事件。请不要建议OLAP。我想更多地探索高级数据网格选项。

<mx:AdvancedDataGrid x="6" y="4" id="adg0" designViewDataType="flat" width="947" height="357" click="summaryViewStack.selectedIndex = 1" fontFamily="Verdana" fontSize="10">



                    <mx:groupedColumns>
                    <mx:AdvancedDataGridColumn headerText="Cluster" dataField="label" />

                    <mx:AdvancedDataGridColumnGroup headerText="Revenue" >
                            <mx:AdvancedDataGridColumn headerText="April" dataField="data1"/>
                               <mx:AdvancedDataGridColumn headerText="May" dataField="data2"/>
                                  <mx:AdvancedDataGridColumn headerText="June" dataField="data3"/>
                                  <mx:AdvancedDataGridColumn headerText="Q1" dataField="data4"/>
                                  </mx:AdvancedDataGridColumnGroup>
                    <mx:AdvancedDataGridColumnGroup headerText="Headcount" >
                            <mx:AdvancedDataGridColumn headerText="April" dataField="data1"/>
                              <mx:AdvancedDataGridColumn headerText="May" dataField="data2"/>
                                 <mx:AdvancedDataGridColumn headerText="June" dataField="data3"/>
                                 <mx:AdvancedDataGridColumn headerText="Q1" dataField="data4"/>
                                 </mx:AdvancedDataGridColumnGroup>
                                    <mx:AdvancedDataGridColumnGroup headerText="Effort" >
                                    <mx:AdvancedDataGridColumn headerText="April" dataField="data1"/>
                                    <mx:AdvancedDataGridColumn headerText="May" dataField="data2"/>
                                    <mx:AdvancedDataGridColumn headerText="June" dataField="data3"/>
                                    <mx:AdvancedDataGridColumn headerText="Q1" dataField="data4"/>
                                    </mx:AdvancedDataGridColumnGroup>

                         </mx:groupedColumns>
                </mx:AdvancedDataGrid>
            </mx:Canvas>
            <mx:Canvas label="Accountwise Summary" width="100%" height="100%">
                <mx:AdvancedDataGrid x="6" y="4" id="adg1" designViewDataType="flat" width="947" height="357" click="summaryViewStack.selectedIndex = 1" fontFamily="Verdana" fontSize="10">
                   <mx:dataProvider>
                     <mx:ArrayCollection>
                        <mx:Object label="1800-Flowers" data1="20" data2="30" data3="40" data4="90" />
                        <mx:Object label="The Home Depot" data1="20" data2="30" data3="40" data4="90" />
                        <mx:Object label="Nielsen" data1="20" data2="30" data3="40" data4="90" />
                        <mx:Object label="Nokia" data1="20" data2="30" data3="40" data4="90" />
                     </mx:ArrayCollection>
                   </mx:dataProvider>


                    <mx:groupedColumns>
                    <mx:AdvancedDataGridColumn headerText="Account" dataField="label"/>

                    <mx:AdvancedDataGridColumnGroup headerText="Revenue" >
                            <mx:AdvancedDataGridColumn headerText="April" dataField="data1"/>
                               <mx:AdvancedDataGridColumn headerText="May" dataField="data2"/>
                                  <mx:AdvancedDataGridColumn headerText="June" dataField="data3"/>
                                  <mx:AdvancedDataGridColumn headerText="Q1" dataField="data4"/>
                                  </mx:AdvancedDataGridColumnGroup>
                    <mx:AdvancedDataGridColumnGroup headerText="Headcount" >
                            <mx:AdvancedDataGridColumn headerText="April" dataField="data1"/>
                              <mx:AdvancedDataGridColumn headerText="May" dataField="data2"/>
                                 ><mx:AdvancedDataGridColumn headerText="June" dataField="data3"/>
                                 <mx:AdvancedDataGridColumn headerText="Q1" dataField="data4"/>
                                 </mx:AdvancedDataGridColumnGroup>
                                    <mx:AdvancedDataGridColumnGroup headerText="Effort" >
                                    <mx:AdvancedDataGridColumn headerText="April" dataField="data1"/>
                                    <mx:AdvancedDataGridColumn headerText="May" dataField="data2"/>
                                    <mx:AdvancedDataGridColumn headerText="June" dataField="data3"/>
                                    <mx:AdvancedDataGridColumn headerText="Q1" dataField="data4"/>
                                    </mx:AdvancedDataGridColumnGroup></mx:groupedColumns>
                </mx:AdvancedDataGrid>

1 个答案:

答案 0 :(得分:1)

听起来你想做的事情应该是可行的,但我认为这不会是微不足道的。

创建一个headerRenderer组件应该非常容易,该组件会调度您可以收听的点击事件。然后根据该点击动态重新创建分组。

你看过FlexMonster Pivot Table Component了吗?我不太了解它,但它似乎是为了解决你的问题而建立的。