views:

37

answers:

1

Hello everybody,

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?

A: 

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>
Organiccat
I had to add matrixProvider.refresh() to the function wich invokes produktMatrix_data.send(). Now it works.At first I thought it doesn't matter, wheter the grouping collection is built inside the dataProvider or used via databinding.
omnibrain
When using a grouping collection you will have to update the dataProvider via the refresh, otherwise most dataproviders operate as expected, just updating them will update anything they are bound to. Advanced Data Grids are not my best friend.
Organiccat