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?
Forums Home / Wijmo / General Discussion
Posted by: dharric on 25 September 2018, 2:59 pm EST
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