2017-04-18 90 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時調用