skratchdot / react-bootstrap-multiselect

A multiselect component for react (with bootstrap). This is a react port of bootstrap-multiselect.
http://projects.skratchdot.com/react-bootstrap-multiselect/
Other
119 stars 62 forks source link

How to deselect options ? #83

Closed yinfanguo closed 6 years ago

yinfanguo commented 6 years ago

The data for the two multiselect is the same, but you can't select the same option, so I should prompted and unselected when selecting the same option. I've seen that bootstrap-multiselect(http://davidstutz.de/bootstrap-multiselect/#methods) has a deselect method, but how can I use the react-bootstap-multiselect?

sman591 commented 6 years ago

I accomplish this by storing a ref to the MultiSelect, and calling syncData() on it whenever the props change.

E.g:

this.setState({ ...some data... })
this.multiselectRef.syncData()
sman591 commented 6 years ago

See: https://github.com/skratchdot/react-bootstrap-multiselect#note-on-data-synchronization