2017-04-18 87 views
0

我想添加选择所有属性到multiselect,我加了onSelectAll道具,但我不能看到选择所有选项。onSelectAll选项不起作用react-bootstrap-multiselect

请参阅下面的代码。

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

我是否缺少任何东西?

回答

0

您需要添加includeSelectAllOption。这是在原来的插件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+')'; }} 

/>

onSelectAll应该是一个函数来描述。此功能将在用户从下拉菜单中选择Select all时调用