Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 144545
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T08:16:13+00:00 2026-05-11T08:16:13+00:00

I have a Collection, and I want to remove all items that have a

  • 0

I have a Collection, and I want to remove all items that have a certain property set to true. I use a filterFunction to accomplish this. My question is, how can I add new items to the Collection that have that property set to true? The filterFunction is still applied, and the item is not added….

Do I have to iterate through the entire collection and remove items one at a time? I thought that that is exactly what refresh() does.

Thanks.

<?xml version='1.0' encoding='utf-8'?> <mx:Application xmlns:mx='http://www.adobe.com/2006/mxml' layout='vertical'>     <mx:Script>         private function hideSpecialItems():void         {             items.filterFunction =                  function (item:Object):Boolean                 {                     return item.isSpecial;                 }              items.refresh();              trace(items.length.toString()); // 2         }          private function addSpecialItem():void         {             items.addItem({name: 'new Special Item', isSpecial: true});              trace(items.length.toString()); // Item is added - returns 3         }          private function addNormalItem():void         {             items.addItem({name: 'new Item', isSpecial: false});              trace(items.length.toString()); // Item not added - returns 2         }     </mx:Script>      <mx:ApplicationControlBar>         <mx:Button label='Hide Items That Aren't Special' click='hideSpecialItems();' />          <mx:Button label='Add a Normal Item' click='addNormalItem();' />          <mx:Button label='Add a Special Item' click='addSpecialItem();' />     </mx:ApplicationControlBar>      <mx:ArrayCollection id='items'>         <mx:Array>             <mx:Object name='item 1' isSpecial='{false}' />             <mx:Object name='item 2' isSpecial='{false}' />             <mx:Object name='item 3' isSpecial='{false}' />             <mx:Object name='item 4' isSpecial='{true}' />             <mx:Object name='item 5' isSpecial='{true}' />             <mx:Object name='item 6' isSpecial='{false}' />         </mx:Array>     </mx:ArrayCollection>      <mx:DataGrid dataProvider='{items}' /> </mx:Application> 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T08:16:14+00:00Added an answer on May 11, 2026 at 8:16 am

    filterFunction doesn’t actually remove the items from the ArrayCollection. It just hides them from the view. You can still see all the items in ArrayCollection.source property.

    If you add new items while filterFunction is still applied, they too are subject to filtering.

    To permanently remove items from a list, convert it to an Array and use Array#filter.

    var newCollection:ArrayCollection =      new ArrayCollection(oldCollection.toArray().filter(myFilterFunction)) 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to remove all items that have Tag set to string Dynamic :
I have a collection that contains all the items that I want to keep
I have Backbone.js collection that holds (for example) 30 items. I want to pass
I have a cart.Lines List and want to remove all items where quantity ==
If I have a collection of static constants that I want to declare centrally
I have a collection of IEnumerable<sentence> (sentence = string) I want to split all
I have a row collection (DataRow[] rows). And I want to import all rows
I have a situation where I want to remove duplicates from a collection (list)
I have a collection of items to save to database, but I want the
I have a necessity to remove all data from mongo collection. Droping of collection

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.