I have an object that looks like this:
[Bindable]
public class MyRecord implements ValueObject
{
public var recall_id:int;
public var recall_type:String;
public var selected:Boolean = false;
public var qty:Number;
public var curr_qty:Number;
public var due_date:String;
public var status:String;
public var comments:String;
public var groupedTrades:ArrayCollection = new ArrayCollection();
}
I stuff a bunch of those in an ArrayCollection and then I use this as a dataProvider for an AdvancedDataGrid:
<mx:dataProvider>
<mx:HierarchicalData
source="{model.recalls}"
childrenField="groupedTrades"/>
</mx:dataProvider>
I have an AdvancedDataGridRenderProvider that I want to display my ‘groupedtrades’:
<mx:rendererProviders>
<mx:AdvancedDataGridRendererProvider
depth="2"
columnIndex="1"
renderer="com.controls.GroupedTradesGrid"
columnSpan="0"/>
</mx:rendererProviders>
In this renderProvider I override the set data function to set the dataProvider:
override public function set data(value:Object):void
{
// If using the array data source, use this instead:
trades_dg.dataProvider = value;
}
The problem is that my renderProvider’s method is invoked for every record in the dataProvider of the ADG it is part of. This amounts to a brand new DataGrid for each trade in groupedTrades.
How do I resolve this? I’m perplexed.
Thanks for any helpful tips, and Happy Thanksgiving!
UPDATE: I just found some hardcoded array from a blog that is doing what I want; a DataGrid as a renderProvider of an AdvancedDataGrid.
private var masterData:Array = [
{ OrderId: 10248, CustomerId:"WILMK", EmployeeId:5, OrderDate:"1-Feb-2007",
children:[
[
{ProductId:11, ProductName:"Quesbo Cabrales", UnitPrice:14, Quantity:12, Discount:0, Price:168},
{ProductId:42, ProductName:"Singaporean Hokkien Fried Mee", UnitPrice:9.8, Quantity:10, Discount:0, Price:98},
{ProductId:42, ProductName:"Mozzarella di Giovanni", UnitPrice:34.8, Quantity:5, Discount:0, Price:174}
]
]}
]
]}
This is from this blog: http://techrays.wordpress.com/2008/04/07/advanced-datagrid-as-an-item-renderer-within-an-advanced-datagrid/#comment-1511
When I debug my collection (recalls is the arraycollection i use) as it is returned from the server I am seeing something like this:
recalls[0] – RecallRecord object
– prop
– prop
– groupedTrades – ArrayCollection that I want to use as DP for renderProvider
groupedTrades[0] – Generic Object
groupedTrades[1] – Generic object
I fail to see the difference between the hardcoded version from the blog that works and the data I’m using from my service. What am I missing?
thank you!
SOLVED:
It turns out that the problem was how I assigned the values to ‘groupedTrades’ when the server responded. I was doing it totally wrong: I was doing a direct assignment instead of adding the ArrayCollection as an element to the ‘groupedTrades’ ArrayCollection.
I was doing this:
Instead of this: