2017-07-17 199 views
2

頁面上有多個多選下拉菜單,因此我們對所有用戶都使用常用選項,但希望爲特定的下拉列表選擇Filteringoption。bootstrap multiselect下拉菜單禁用篩選不起作用

選項:

function getOptions(isFilter) { 
    return { 
     enableFiltering: isFilter, 
     enableCaseInsensitiveFiltering: true, 
     filterPlaceholder: 'Search ...', 
     nonSelectedText: node, 
     numberDisplayed: 1, 
     maxHeight: 400, 
    } 
} 

$('#DDLState').multiselect(getOptions(true)); //enable Filtering true working ok 

$('#DDLCity').multiselect(getOptions());//enable Filtering false not working 

但啓用過濾兩種。

回答

1

你的問題是,在這個屬性:

enableCaseInsensitiveFiltering: true, 

將其更改爲:

enableCaseInsensitiveFiltering: isFilter, 

documentation

enableCaseInsensitiveFiltering:如上配置將要使用的過濾器區分大小寫的過濾,通過設置enableCaseInsensitiv eFiltering爲true,可以將此行爲更改爲使用大小寫不敏感的過濾。

的片段:

function getOptions(isFilter) { 
 
    return { 
 
     enableFiltering: isFilter, 
 
     enableCaseInsensitiveFiltering: isFilter, 
 
     filterPlaceholder: 'Search ...', 
 
     nonSelectedText: 'Check an option!', 
 
     numberDisplayed: 1, 
 
     maxHeight: 400, 
 
    } 
 
} 
 

 
$('#DDLState').multiselect(getOptions(true)); 
 
$('#DDLCity').multiselect(getOptions());
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> 
 
<script src="https://code.jquery.com/jquery-2.1.1.min.js"></script> 
 
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> 
 
<link rel="stylesheet" href="https://rawgit.com/davidstutz/bootstrap-multiselect/master/dist/css/bootstrap-multiselect.css"> 
 
<script src="https://rawgit.com/davidstutz/bootstrap-multiselect/master/dist/js/bootstrap-multiselect.js"></script> 
 

 

 
<div class="container-fluid"> 
 
    <div class="row"> 
 
     <div class="col-xs-6 col-md-4"> 
 
      <select id="DDLState" multiple="multiple"> 
 
       <option value="cheese">Cheese</option> 
 
       <option value="tomatoes">Tomatoes</option> 
 
       <option value="mozarella">Mozzarella</option> 
 
       <option value="mushrooms">Mushrooms</option> 
 
       <option value="pepperoni">Pepperoni</option> 
 
       <option value="onions">Onions</option> 
 
      </select> 
 
     </div> 
 
     <div class="col-xs-6 col-md-4"> 
 
      <select id="DDLCity" multiple="multiple"> 
 
       <option value="cheese">Cheese</option> 
 
       <option value="tomatoes">Tomatoes</option> 
 
       <option value="mozarella">Mozzarella</option> 
 
       <option value="mushrooms">Mushrooms</option> 
 
       <option value="pepperoni">Pepperoni</option> 
 
       <option value="onions">Onions</option> 
 
      </select> 
 
     </div> 
 
    </div> 
 
</div>

+0

謝謝,這意味着如果在使用enableCaseInsensitiveFiltering選項,然後沒有必要列入enableFiltering選項。 –