bootstrap-select
bootstrap-select copied to clipboard
Live search For optgroups
I'll be happy if could search the optgroups
If by live search optgroups, you mean typing in part of the optgroups value for it to find all options in said optgroup, then you can sort of do it.
I did it by adding the value of an optgroup as a data-tokens to each of the option in the optgroup.
[edit]
example:
<optgroup label="Food">
<option data-tokens="food green">Iceberg</option>
<option data-tokens="food green">Cucumber</option>
<option data-tokens="food red">Tomato</option>
<option data-tokens="food orange">Carrot</option>
</optgroup>
then it should find all the options in that group if you live search for "food"
I have tried it in that way actually, but it doesn't work. I don't know the reason. And now, the data-tokens doesn't work perfectly, maybe it's affectted by other js framework.
Works for me. Thx!
As I need to use long names in my selectlist items (and optgroups) this solution doesn't really work for me. Including the group names in the live-search would be awesome...
It worked for me, 2022