0

I see questions about properly filtering a CollectionView. None of the prescriptions are working for me. I must not be getting the concept.

If I have a collection of models, and I want to show only those with an attribute "visible" set to "true", I should filter the collection in the CollectionView. I thought this was the right way to do that:

    var myCollectionView = new MyCollectionView ({
        collection: new FilteredCollection(UnfilteredCollection.where({ visible: 'true' }))                
    });

When I add 10 models to UnfilteredCollection, 5 with visible=false and 5 with visible=true, and show myCollectionView in a region, I should see 5 items. I'm getting none.

If I drop the filter and just show the UnfilteredCollection, I see all 10 items, so I know I'm wired right other than this filtered stuff.

Setting a VS breakpoint I can see the proper values in the collection's models - 5 visible=false and 5 visible=true.

What am I missing here?

Robert
  • 828
  • 2
  • 13
  • 28

1 Answers1

0
{ visible: 'true' }

That makes me think you might accidentally add quotes around true value, which makes it a string, while you might have boolean true/false in your models

Yura
  • 2,690
  • 26
  • 32
  • Thanks for response. Definitely a string in model. Tried without quotes anyway just to be safe but no dice. – Robert Sep 24 '14 at 14:27
  • No, I am mistaken. That is the issue. Another issue was masking the success of that fix. The other issue is that I was not making a new view instance after adding models. Was under the mistaken impression that the existing instance would pick up new models. Still a little confused by that. Thought the idea of CollectionView was define one instance and it would react to underlying collection adjustments? Seems like that would be logical. Not the case? When I make a new view instance after each collection adjustment the updates are reflected. – Robert Sep 24 '14 at 17:27