ComboBox set previous value

Posted by: germiep.fernandez on 8 February 2022, 8:48 pm EST

    • Post Options:
    • Link

    Posted 8 February 2022, 8:48 pm EST

    Hi,

    Is it possible to re set the value of the combo box to its previous value before the itemsSource change? I have a logic where the language of the page will change, but I want to retain the previously selected combo boxes.

  • Posted 10 February 2022, 1:20 am EST

    Hello,

    You may handle the isDroppedDownChanged and itemsSourceChanged event of the ComboBox to store and restore the selectedItem respectively. Please refer to the code snippet and sample link below for reference:​

          
      theComboObject.isDroppedDownChanged.addHandler((s, e) => {
        //store pre-selected item
        preSelectedItem = theComboObject.selectedItem;
      });
    
      theComboObject.itemsSourceChanged.addHandler((s, e) => {
        //restore the selected item
        theComboObject.selectedItem = theComboObject.itemsSource.find(
          (i) => i.id == preSelectedItem.id
        );
      });
    
    

    Sample link:https://stackblitz.com/edit/js-hzo1jq?file=index.js

    Regards

  • Posted 22 February 2022, 7:19 pm EST

    Sorry for the late reply. Thank you for this. I will try to use this as solution.

Need extra support?

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

Learn More

Forum Channels