How to change selectedvalue of combobox

Posted by: dharric on 25 September 2018, 2:59 pm EST

    • Post Options:
    • Link

    Posted 25 September 2018, 2:59 pm EST

    I would like to programmatically change the selectedvalue in a combobox can I do it with the selectedValue property instead of selectedIndex?

  • Posted 26 September 2018, 1:00 am EST

    Hi,

    Yes, you may use selectedValue to change the selected value of ComboBox but first, you need to set selectedValuePath property of the ComboBox.

    Please refer to the following code snippet:

    cbInit(cb) {
        cb.selectedValue = 4;
      }
    
      render() {
        return (
          <div style={{height:"300px"}}>
            <WjInput.ComboBox
              selectedValuePath='id'
              displayMemberPath='id'
              itemsSource={this.state.tempDate}
              initialized={this.cbInit.bind(this)}
              ></WjInput.ComboBox>
          </div>
        );
      }
    

    You may also refer to the following sample: https://stackblitz.com/edit/react-6gxhsj?file=index.js

    ~Sharad

Need extra support?

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

Learn More

Forum Channels