That's a good suggestion.  Unfortunately I can't directly keep track of the 
ListCollectionViews unlike in the example.  I have a function that returns 
these views with different filtering functions.  I might be able to listen for 
COLLECTION_CHANGED on the ArrayCollection and call refresh then.

Unfortunately I have another problem, but I'm unable to distill it into a small 
example, which is that when the list has one item in it, and another is added, 
it appears that a duplicate of the first item was made.  I am going to put off 
what I'm working on for now and see if we can switch to Flex 3 later.

Thanks for your help.

Ben

--- In flexcoders@yahoogroups.com, "Tim Hoff" <timh...@...> wrote:
>
> 
> Ran your code with Flex 2.0.1 Hotfix 3 and was able to reproduce.  The
> first suggestion worked.  Fixed it with:
> 
> public function addItem():void {
>      trace("adding item", stuff.length);
>       stuff.addItem({label: stuff.length});
>       filtered_stuff.refresh();
> }
> 
> -TH
> 
> --- In flexcoders@yahoogroups.com, "bnjmnhggns" <bhiggins@> wrote:
> >
> > I'm trying to find the bug and there's some that are close, like this
> one: https://bugs.adobe.com/jira/browse/SDK-11852
> >
> > Do you know if there's a workaround for Flex 2?
> >
> > Thanks,
> >
> > Ben
> >
> > --- In flexcoders@yahoogroups.com, Alex Harui aharui@ wrote:
> > >
> > > Tim, did you try that in Flex 2? I seem to recall it being a bug.
> > >
> > > Alex Harui
> > > Flex SDK Developer
> > > Adobe Systems Inc.<http://www.adobe.com/>
> > > Blog: http://blogs.adobe.com/aharui
> > >
> > > From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com]
> On Behalf Of Tim Hoff
> > > Sent: Monday, April 06, 2009 12:17 PM
> > > To: flexcoders@yahoogroups.com
> > > Subject: [flexcoders] Re: ListCollectionView w/ a filterFunction as
> a dataProvider - Flex 2
> > >
> > >
> > > Hmm, ran your code and it worked fine. Clicked the add item button
> the first time and "1" showerd up. Maybe try adding
> filtered_stuff.refresh(); to the addItem function.
> > >
> > > -TH
> > >
> > > --- In flexcoders@yahoogroups.com, "bnjmnhggns" <bhiggins@> wrote:
> > > >
> > > > Hi all, I've been having weird problems involving Lists,
> dataProviders, ListCollectionViews with and ArrayCollections. I was able
> to reproduce one of my problems below.
> > > >
> > > > I have a ListCollectionView (filtered_stuff) that's viewing an
> ArrayCollection (stuff). stuff initially just has one element.
> filtered_stuff has a filterFunction that filters out this element.
> > > >
> > > > Here's the weird part. Clicking on Add item once does not show the
> added item in the List. Clicking on Add item again will result in TWO
> items showing up in the list. After that, clicking Add item behaves as
> you might expect.
> > > >
> > > > Why is it behaving this way?
> > > >
> > > > Thanks,
> > > >
> > > > Ben
> > > >
> > > > Code:
> > > >
> > > > <?xml version="1.0"?>
> > > > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";>
> > > ! > <mx:Panel title="List dataProvider test"
> creationComplete="onCreate()"
> > > > paddingTop="10" paddingBottom="10" paddingLeft="10"
> paddingRight="10">
> > > >
> > > > <mx:List id="list" width="100%" dataProvider="{filtered_stuff}"/>
> > > > <mx:Button click="addItem()" label="Add item"/>
> > > > </mx:Panel>
> > > >
> > > > <mx:Script>
> > > > <![CDATA[
> > > > import mx.collections.ListCollectionView;
> > > > import mx.collections.ArrayCollection;
> > > >
> > > > [Bindable] public var stuff:ArrayCollection;
> > > > [Bindable] public var filtered_stuff:ListCollectionView;
> > > >
> > > > public function addItem():void {
> > > > trace("adding item", stuff.length);
> > > > stuff.addItem({label: stuff.length});
> > > > }
> > > >
> > > > public function onCreate():void {
> > > > stuff = new ArrayCollection([{label: 0}]);
> > > > filtered_stuff! = new ListCollectionView(stuff);
> > > > filtered_stuff.! fil terFunction = function(item:Object):Boolean {
> > > > return item.label > 0;
> > > > }
> > > > filtered_stuff.refresh();
> > > > }
> > > > ]]>
> > > > </mx:Script>
> > > > </mx:Application>
> > > >
> > >
> >
>


Reply via email to