Can we dynamically add a component multiple times and still retrieve information fired by these similar components uniquely in the parent component? I need to create a filter that shows fields, operator and value to be selected by the user. I will be creating a component for just a row of this kind and user can add / remove multiple filters. Can I collect data from these components uniquely when all these components will be firing the same event?

1 Answer 1


For a filtering mechanism, you probably want to apply all the filters, so you'll likely want to read all of them anyways. In addition, you'll probably want to bind the filter data to an attribute anyways. As such, your design would probably look like this:

<aura:attribute name="filters" type="Object[]" default="[]" />

<aura:iteration items="{!v.filters}" var="filter">
  <c:filterRow value="{!filter}" onupdate="{!c.applyFilters}" />

  applyFilters: function(component, event, helper) {
    var filters = component.get("v.filters");
    // process filter information

This isn't the only way to do this, but it's probably the easiest. Using component.find will only complicate your logic slightly, and other methods are probably less intuitive than this.

  • Hi @sfdcfox, I dont have any items to show in the iteration cmp! The user will be adding / removing the filters as he pleases. This is similar to creating a list view (adding fields in the list view filter). Do you mean that on click of "add" I should add a row of the new component in the list? Commented Feb 12, 2018 at 6:38
  • @AdityaSagam Yes, that would be the idea.
    – sfdcfox
    Commented Feb 12, 2018 at 7:12
  • Thats cool! I'll let you know how it goes.. Thanks :) Commented Feb 12, 2018 at 7:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .