bootstrap-select icon indicating copy to clipboard operation
bootstrap-select copied to clipboard

Live search For optgroups

Open xiaopeng-he opened this issue 8 years ago • 5 comments

I'll be happy if could search the optgroups

xiaopeng-he avatar Feb 14 '17 09:02 xiaopeng-he

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"

dnatabar avatar Feb 14 '17 19:02 dnatabar

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.

xiaopeng-he avatar Feb 15 '17 02:02 xiaopeng-he

Works for me. Thx!

lautaros86 avatar Nov 16 '17 13:11 lautaros86

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...

borrmann avatar Aug 09 '19 09:08 borrmann

It worked for me, 2022

GilbertoScript avatar Feb 18 '22 13:02 GilbertoScript