开发者

Adobe Flex arraycollection

I want to use single collection object to two different UI components. 1. Datagrid and 2nd is chart component. I dont want to change anything inside the arraycollection object but I want to use it at the same time with two different component with minor changes. I know we can use filter function some how but not sure how to a开发者_如何转开发pply filter to arraycollection object so that one component (datagrid) can use the original arraycollection object and second component (chart) used the modified one.

Thanks,


If you use the same ArrayCollection as the dataProvider for two different components, then any filter or sort applied to that ArrayCollection will show up in both components.

What you want to do cannot be done.

However, you can create multiple ArrayCollections based on the same source and apply filters to them differently. Conceptually something like this:

public var arrayCollection1 : ArrayCollection = new ArrayCollection();
public var arrayCollection2 : ArrayCollection = new ArrayCollection();

protected function onIGotTheArray(value:Array):void{
 arrayCollection1.source = value;
 arrayCollection2.source = value;
 dataGrid.dataProvider = arrayCollection1;
 chart.dataProvider = arrayCollection2;
}

Now you can apply a filter to the first arrayCollection without affecting the second arrayCollection, or vice versa.

This is the preferred approach in my experience.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜