Currently I am customizing multiple selection drop-down list of Multiple Selection Plugin and these are the behaviors that I am going to apply on my customized selection :
(1), (2), and (4) I have already accomplished it. But for (3), I have not come up with any solution yet.
This is the sample json string of the multi selection :
var _str = '{"10":{"0":"0","1":"DISPONIBILITES","2":"t","style":"font-weight: bold;"},"16":{"0":"0","1":"TRESORERIE NETTE","2":"t","style":"font-weight: bold;"},...."}}}';
Here is the https://jsfiddle.net/skL589uu/7/ that I created.
It would be great if anyone here could give me some idea about that.
You don't have to write any custom logic for that, multi-select.js
provides a feature called optGroups
.
just group the child items under the parent group in the HTML and the rest is taken care.
Here is link to official docs, Multi-select OptGroups
HTML CODE:
<select multiple="multiple">
<optgroup label="Group 1">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</optgroup>
<optgroup label="Group 3">
<option value="15">15</option>
</optgroup>
</select>
JQUERY CODE:
$(function() {
$("select").multipleSelect({
multiple: true,
multipleWidth: 55,
width: '100%'
});
});
Live Demo @ JSFiddle
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With