iirc what I usually do is store my "master" list data (the one in my model) in an appropriate collection (more on this later). I then create a second ArrayCollection in each view that needs to filter and set the source of that one to the model collection (property that exposes an Array). I then bind my view components to the local array collection. Any view specific filtering is applied to the view local array collection, this way the other views are not filtered. I think the trick with using ArrayCollection (again iirc) is that it will not fire a change to the source property unless that property is explicitly set... so you will not get updated unless you replace the whole source array if you bind to that. You may be able to bind to the ArrayCollection.list property (not sure I have ever tried). I have created custom collection classes that expose a read only "values" property that will fire bindings when the values in the collection change... so I rarely deal with this any more (see end of message for tip re: how to do that).

Below is an example. In this example I bound my view local ArrayCollection.source to a custom Hashtable (wrapper on Dictionary that makes things bindable and mimics the Java Hashtable class interface) class that I have written that fires bindings whenever its stored data changes. This should get you close... the important things here are

1) Bind views to a local collection that can be filtered locally
2) Bind the local collection to something that will fire the binding when it changes

<mx:ArrayCollection id="peopleAC" source="{this._model.people.values}" filterFunction="filterPerson"/>

<mx:DataGrid id="peopleGrid" dataProvider="{this.peopleAC}" width="100%" height="100%">

hth
Scott

--
Scott Melby
Founder, Fast Lane Software LLC
http://www.fastlanesw.com



FYI: here is how my custom Hashtable collection defines its read only values property to make it bindable.

     /**
     * This property exposes the values stored in the underlying
     * dictionary.  Because it is Bindable on the "change" event
     * anything bound to this property will update whenever this
     * Hashtable dispatches a "change" event.
     */
     [Bindable (event="change")]
     public function get values():Array


kyleashipley wrote:

Sorry to dredge up an old thread, but I'm having a similar problem
that can't be helped by the links provided.

In our system, we have a shared list collection that is filtered in
different ways for different views, but no button to enact the filter.
For example, we have a list of users that consists of buddies, chat
room participants, blocked users, etc. If we apply the filter
directly to the list, it will affect the other views. If we create a
ListViewCollection, I don't think the bindings get updated correctly.
(I could be wrong on that point.)

Is there a way to combine the ListViewCollection solution with data
binding to create a filtered list that updates when the original data
source updates?

>
> It's always worth looking through the archives.
>
> From a previous post of mine:
>
> Check out ListCollectionView. I've been down that same road. (Feb
Thread:
> any ArrayCollection tricks?)
>
> From the thread: "I found a great example here, which is perfect:
>
http://viconflex.blogspot.com/2006/11/listcollectionview-different.html <http://viconflex.blogspot.com/2006/11/listcollectionview-different.html> "
>
> Paul
>
> snip
>


Reply via email to