How to redraw combobox after items display values have changed

Posted by: sicrum on 21 January 2020, 4:18 am EST

    • Post Options:
    • Link

    Posted 21 January 2020, 4:18 am EST - Updated 3 October 2022, 9:13 am EST

    Hello

    https://stackblitz.com/edit/angular-zyka4b?file=app%2Fapp.component.ts

    Refer to the demo.

    What it shows?

    1. Combobox with 2 items ‘name1’ and ‘name2’
    2. Button that appends ‘new’ suffix to items names
    3. JSON with source items

    What is an issue?

    1. After I click the button combobox is not updated with new values
    2. Refer screenshot:

    Invalidate() and Refesh() didnt help.

    Also, I cant re-assign itemsSource because of complicated logic related to selected index change event

  • Posted 21 January 2020, 6:33 pm EST

    Hi,

    Since you have updated the collection instead of the ComboBox, you will need to refresh the CollectionView of the ComboBox like this:

    cb.collectionView.refresh();
    

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

    Regards,

    Ashwin

  • Posted 21 January 2020, 11:36 pm EST

    thanks!

Need extra support?

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

Learn More

Forum Channels