页面上有多个多选下拉菜单,因此我们使用常用选项,但希望为特定下拉列表选择Filteringoption。
选项:
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
但是为两者启用了过滤。
答案 0 :(得分:2)
您的问题出在这个属性中:
enableCaseInsensitiveFiltering: true,
将其更改为:
enableCaseInsensitiveFiltering: isFilter,
enableCaseInsensitiveFiltering :上面配置的过滤器将使用区分大小写的过滤,通过将enableCaseInsensitiveFiltering设置为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>