Two multiselects with same source can't have different selections?

Posted by: stefan.brenner.a on 28 October 2019, 8:55 am EST

    • Post Options:
    • Link

    Posted 28 October 2019, 8:55 am EST

    Hi,

    I have the case that I have two wj-multi-selects in a form and both share the same source which is what I need. However both multi selects should handle a different selection but if I select something in the first control and then in the second the selection from the first control will also be in the second control. Also the two separate selection lists in the background get synced which is not what I want.

    You can try out what I mean in the following example:

    https://stackblitz.com/edit/angular-c3glfj

    Can you please tell me how to change this behavior so that the two selection lists are handled separately?

    Thanks and best regards,

    Stefan

  • Posted 30 October 2019, 1:07 am EST

    Hi Stefan,

    You will need to create a copy of the original source variable and assign it to the second MultiSelect control. In this way, the collectionView of both the MultiSelect will not point to the same source and therefore can be selected differently. Refer to the updated sample below:

    https://stackblitz.com/edit/angular-x38nda

    Regards,

    Ashwin

  • Posted 31 October 2019, 2:31 am EST

    Hi Ashwin,

    this works of course but is this the intended behavior of the control? I work with ngrx and my store creating a copy of my items just to allow two multiselects choosing from it doesn’t seem very clean to me.

    Thanks and best regards,

    Stefan

  • Posted 31 October 2019, 11:59 pm EST

    Hi Stefan,

    This is expected behavior because the MultiSelect control keeps the track of the checked items by adding a $checked property to the main itemsSource. If the source of both the MultiSelect is the same, then they both will point to the same array and if $checked property is added by the first MultiSelect, it will also show in the second MultiSelect.

    I hope this clears your doubts but feel free to revert back in case you have any additional queries.

    ~regards

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels