[英]Multiple selection dropdown list with jquery
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. (1),(2)和(4)我已经完成了。 But for (3), I have not come up with any solution yet.
但是对于(3),我还没有提出任何解决方案。
This is the sample json string of the multi selection : 这是多重选择的示例json字符串:
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. 这是我创建的https://jsfiddle.net/skL589uu/7/ 。
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
. 您不必为此编写任何自定义逻辑,
multi-select.js
提供了一个称为optGroups
的功能。
just group the child items under the parent group in the HTML and the rest is taken care. 只需将子项归类到HTML的父组下,其余的都应当心。
Here is link to official docs, Multi-select OptGroups 这是官方文档的链接, 多选OptGroups
HTML CODE: HTML代码:
<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: JQUERY代码:
$(function() {
$("select").multipleSelect({
multiple: true,
multipleWidth: 55,
width: '100%'
});
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.