Search code examples
reactjsbootstrap-multiselect

onSelectAll option is not working in react-bootstrap-multiselect


I want to add select all property to multiselect, I added onSelectAll prop but I cant see select all option.

See below code.

<Multiselect 
     data={this.props.list} 
     multiple 
     ref="industry" 
     onSelectAll 
     onChange={this.handleDropdown.bind(this, 'industry')} 
     buttonText={function(options, select) { 
                     return 'Industry ('+ options.length+')'; }} 
/>

Am I missing anything?


Solution

  • You need to add includeSelectAllOption. This is described in the original plugin here

    <Multiselect 
     data={this.props.list} 
     includeSelectAllOption
     multiple 
     ref="industry" 
     onSelectAll={this.selectAll} 
     onChange={this.handleDropdown.bind(this, 'industry')} 
     buttonText={function(options, select) { 
                     return 'Industry ('+ options.length+')'; }} 
    

    />

    Your onSelectAll should be a function. This function will be called when the user selects Select all from the dropdown