0
votes

In terms of data integrity, I think having an object with its children as an ArrayCollection is just fine. So why is my AdvancedDataGrid renderProvider rendering each child node instead? I just don't get it. ( My renderProvider is a DataGrid ). This results in a new datagrid for each new item.

I'm hoping I don't have to rewrite my data structure.

Here's the code:

recalls.addItem( 
                new ObjectProxy(
                    {
                        dueDate:'7/1/2011',
                        status:'New',
                        comments:'',
                        children:new ArrayCollection( [
                            {
                                rate:-5.25,
                                qty:20000,
                                recallQty:20000
                            },
                            {
                                rate:-5.25,
                                qty:5000,
                                recallQty:5000
                            }
                        ]),
                        items:new ArrayCollection([
                            {
                                rate:-5.25,
                                qty:1700,
                                recallQty:1700
                            },
                            {
                                rate:-5.25,
                                qty:6450,
                                recallQty:6450
                            }
                        ])
                    }
                )
            );
            recalls.addItem( 
                new ObjectProxy(
                    {
                        selected:false,
                        id:1002,
                        rebate:-2,
                        div:100,
                        dueDate:'8/9/2011',
                        status:'New',
                        comments:'',
                        children:new ArrayCollection([
                            {
                                sid:32555688,
                                rate:-2,
                                qty:7500,
                                recallQty:7500
                            },
                            {
                                rate:-2,
                                qty:3500,
                                recallQty:3500
                            }
                        ]),
                        items:new ArrayCollection([
                            {
                                rate:-2,
                                qty:3200,
                                recallQty:3200
                            },
                            {
                                rate:-2,
                                qty:2200,
                                recallQty:2200
                            }
                        ])
                    }
                )
            );

The above arraycollection is the dataProvider for my AdvancedDataGrid. Here's the DP for the ADG.

<mx:dataProvider>       
                        
                        <mx:HierarchicalData 
                            source="{recalls}"/>      
                        
                    </mx:dataProvider>

Here's the code for the renderProvider for this ADG:

<mx:rendererProviders>
                        
                        <mx:AdvancedDataGridRendererProvider 
                            depth="2" 
                            columnIndex="1" 
                            renderer="com.controls.GroupedTradesGrid"
                            columnSpan="0"/>
                        
                    </mx:rendererProviders> 

Inside this renderProvider, I use this code to set the DP:

override public function set data(value:Object):void
        {
            // If using the array data source, use this instead:
            dataProvider = value;
            
            // adjust rowCount
            this.rowCount = dataProvider.length + 1;
        }

Basically, a new DataGrid is being created for each element in the 'children' collection...instead of one datagrid being created and the 'children' collection populating it. Why is that?

Thanks for any helpful tips!

1

1 Answers

0
votes

Not sure I get what you are doing but your dataProvider should be an ArrayCollection not an object.

dataProvider = "{ObjectProxy.children}"