tags:

views:

489

answers:

2

How can I populate multiple datagrids in flex with a single datasource that is filtered differently for each datagrid. I'm assigning the event.result from my remote object call to three different array collections, each with its own filter function. When I assign and refresh the filter functions, they each affect all array collections. So, the results of the last array collection refresh end up in all three datagrids.

+2  A: 

I would make copies of your data provider, ie:

var myDataArray:Array; // this contains your original data.

dataGrid1.dataProvider = new ArrayCollection(myDataArray.concat()); 

dataGrid2.dataProvider = new ArrayCollection(myDataArray.concat());

dataGrid3.dataProvider = new ArrayCollection(myDataArray.concat());
quoo
um, reason for downvote please?
quoo
+3  A: 

You probably need to use ObjectUtil.copy on your event result to have 3 separate ArrayCollections, one for each DataGrid... otherwise they all point at the same memory location of the single ArrayCollection and any changes made to it will be reflected in all DataGrids.

var AC1:ArrayCollection = event.result as ArrayCollection;
var AC2:ArrayCollection = ObjectUtil.copy(AC1) as ArrayCollection;
var AC3:ArrayCollection = ObjectUtil.copy(AC1) as ArrayCollection;
Chris Klepeis
thanks - worked perfectly!
dfran
Very good answer
Rahul Garg