Flex AdvancedDatagrid populating with groupingCollection based on xml

泄露秘密 提交于 2019-12-12 03:54:12

问题


I'm currently trying to populate an flex 3 AdvancedDatagrid with xml received from a HTTPService with id="produktMatrix_data". The layout is as follows: http://pastebin.com/NqFqgj86 The result should look like:

The further rows like KID, M.., etc. will be populated by other sources, be hardcoded, or by user input and are beyond scope of this question. My code for the AdvencedDataGrid is as follows:
<mx:AdvancedDataGrid dataProvider="{matrixProvider}">  
<mx:columns> 
    <mx:AdvancedDataGridColumn headerText="Zielprodukt" dataField="prod_txt" editable="false" >            
    </mx:AdvancedDataGridColumn>                        
    <mx:AdvancedDataGridColumn headerText="KID" dataField="kid" editable="true" editorDataField="selectedItem" >
    </mx:AdvancedDataGridColumn>
    <mx:AdvancedDataGridColumn headerText="MVLZ-Bezug" dataField="mvlz_bez" >
    </mx:AdvancedDataGridColumn>
    <mx:AdvancedDataGridColumn headerText="MVLZ-Dauer" dataField="mvlz_dauer">
    </mx:AdvancedDataGridColumn>
    <mx:AdvancedDataGridColumn headerText="MVLZ-Einheit" dataField="mvlz_einheit">
    </mx:AdvancedDataGridColumn>
    <mx:AdvancedDataGridColumn headerText="Status" dataField="status" editable="true">
    </mx:AdvancedDataGridColumn>
    <mx:AdvancedDataGridColumn headerText="Prämierung" dataField="praemie" editable="true">
    </mx:AdvancedDataGridColumn>
    <mx:AdvancedDataGridColumn headerText="Gültig ab" dataField="datum_ab" editable="true">
    </mx:AdvancedDataGridColumn>
    <mx:AdvancedDataGridColumn headerText="Gültig bis" dataField="datum_bis" editable="true">
    </mx:AdvancedDataGridColumn>
</mx:columns>

The dataProvider is coded:

    <mx:GroupingCollection id="matrixProvider" source="{produktMatrix_data.lastResult.result.pos.entry}" childrenField="undefined">
    <mx:Grouping>
        <mx:GroupingField name="portfolio"/>
        <mx:GroupingField name="layer"/>
        <mx:GroupingField name="cluster"/>
        <mx:GroupingField name="prod_txt"/>
    </mx:Grouping>
</mx:GroupingCollection>

But that doesn't populate the AdvancedDataGrid. So, how do I have to tweak my code to make it work? Or should I choose a completely differnt approach?


回答1:


There's actually a pretty good example of this on the livedocs site:

http://livedocs.adobe.com/flex/3/html/help.html?content=advdatagrid_08.html

Basically, it has you put the groupingcollection inside the datagrid, which (copy/paste) looks like this:

<mx:AdvancedDataGrid id="myADG" 
        width="100%" height="100%" 
        initialize="gc.refresh();">        
        <mx:dataProvider>
            <mx:GroupingCollection id="gc" source="{dpFlat}">
                    <mx:Grouping>
                        <mx:GroupingField name="Region"/>
                        <mx:GroupingField name="Territory"/>
                    </mx:Grouping>
            </mx:GroupingCollection>
        </mx:dataProvider>        

        <mx:columns>
            <mx:AdvancedDataGridColumn dataField="Region"/>
            <mx:AdvancedDataGridColumn dataField="Territory"/>
            <mx:AdvancedDataGridColumn dataField="Territory_Rep"
                headerText="Territory Rep"/>
            <mx:AdvancedDataGridColumn dataField="Actual"/>
            <mx:AdvancedDataGridColumn dataField="Estimate"/>
        </mx:columns>
   </mx:AdvancedDataGrid>


来源:https://stackoverflow.com/questions/3975445/flex-advanceddatagrid-populating-with-groupingcollection-based-on-xml

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!