Flex AdvancedDatagrid populating with groupingColl

2019-09-02 07:06发布

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: adg 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条回答
何必那么认真
2楼-- · 2019-09-02 07:35

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>
查看更多
登录 后发表回答