bootstrap multiselect dropdown disable Filtering not working

Govind Samrow picture Govind Samrow · Jul 17, 2017 · Viewed 7.4k times · Source

There is multiple multiselect dropdowns on a page so we using common option for all but want to select Filteringoption for specific dropdowns .

Options:

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

But Filtering enabled for both.

Answer

gaetanoM picture gaetanoM · Jul 17, 2017

Your issue is in this property:

enableCaseInsensitiveFiltering: true,

Change it to:

enableCaseInsensitiveFiltering: isFilter,

From the documentation:

enableCaseInsensitiveFiltering: The filter as configured above will use case sensitive filtering, by setting enableCaseInsensitiveFiltering to true this behavior can be changed to use case insensitive filtering.

The snippet:

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>