Topic: hide optgroup on search mdbootstrap
hubertthalmann pro premium asked 5 years ago
Im working with MDBootrap's Select Module.
Im using "Options groups" like
<select class="mdb-select md-form">
<optgroup label="team 1">
<option value="1">Option 1</option>
<option value="2">Option 2</option>
</optgroup>
<optgroup label="team 2">
<option value="3">Option 3</option>
<option value="4">Option 4</option>
</optgroup>
</select>
and i am using the "searchable" ability.
so it looks like:
<select class="mdb-select md-form" searchable="Search and add here...">
<optgroup label="team 1">
<option value="1">Option 1</option>
<option value="2">Option 2</option>
</optgroup>
<optgroup label="team 2">
<option value="3">Option 3</option>
<option value="4">Option 4</option>
</optgroup>
</select>
its all working fine. My only problem ist that if i search something, it shows all the empty groups where nothing was found, is there a way to hide these groupts?
solution 1: hide all groups on searching
solution 2: "search" the groups, and if my keyword is not on the groups name and none of the groups item it hides the full group?
has anyone an idea how to achieve this?
thanks is advance.
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Open
- User: Pro
- Premium support: No
- Technology: MDB jQuery
- MDB Version: 4.12.0
- Device: PC
- Browser: Chrome
- OS: Windows
- Provided sample code: No
- Provided link: No
Grzegorz Bujański staff commented 5 years ago
Hi. At the moment select does not offer this option. But I'm add this to our ideas list, and maybe we'll add it someday.
hubertthalmann pro premium commented 5 years ago
thanks for your answer.
is there a workaround? can i get the searchbox change event via jquery and if the value is not null or empty i add a "hide" class to li.optgroup?
Grzegorz Bujański staff commented 5 years ago
We don't have a workaround, but your suggestion should work.