Search code examples
apache-flexsearchdatagridadvanceddatagridarraycollection

Remove Selected Items from Search Results


Use Case:

  1. End-User searches for something and an ArrayCollection is returned with Result objects. This is displayed in a data grid.
  2. End-User selects a few of the search results and "moves" it over to another datagrid for use later.
  3. End-User does another search.

PROBLEM: Some of the search results might contain something the user already previously selected and moved over to the second datagrid. I want to remove these from the second search result.

How can I do this quickly, and efficiently in Flex code?


Solution

  • disableAutoUpdate() on both array collection

    loop through the first one and for each item of the second remove it if it's present in the first one (or adapt the algorithm based on what you really want - unsure)

    enableAutoUpdate() at the end.

    Looping through array collection can be quick if no events are dispatched.

    Second option, you could also loop through a cheap copy made up of an array, which is arraycollection.source.concat(), or even a vector if all your items are of the same type. That will give the maximum speed, but you might lose in the long run as you need to convert back to an array collection at the end.

    So I would stick to the first option.