views:

844

answers:

1

(I'm using Cairngorm) I have a combobox that displays items form an XMLListCollection that's in my model. I want to only view the items (XML) whose "sent" properties is false.. like item.sent == 'false'. This filter must apply only to this specific combobox, not everything that's bound to the XMLListCollection source. And of course it must update and refresh the filter if the source changes..

How can I do it? I'm trying to use filterFunction but don't understand how it works... thanks

+2  A: 

Actually, you don't have to copy all the data, as Christophe says. You can create another ListCollectionView which is actually a view of some list and apply filter to it. So if xmlListCollection is your collection, you can try the following code:

var listView:ListCollectionView = new ListCollectionView(xmlListCollection.list);
listView.filterFunction =  someFunction;
listView.refresh();

listView should be always in sync with your collection, unless you swap underlying xmlListCollection source or list.

Hrundik
That actually made my day. I can't believe I didn't know that since I've been working around this for a couple of times in recent projects. +1
Christophe Herreman