Tree Multiselect是一个jQuery插件,它可以将多选框转换为带有复选框的可折叠树状视图,以便轻松选择选项。用户可以在展开视图中删除所选项目中的选择,也可以取消选中选择选项。
- # Yarn
- $ yarn add tree-multiselect
- # NPM
- $ npm install tree-multiselect --save
1.在html页面上包含jQuery库和jQuery树多选插件的JS和CSS文件。
- <link href="jquery.tree-multiselect.min.css" rel="stylesheet">
- <script src="//code.jquery.com/jquery-1.11.3.min.js"></script>
- <script src="jquery.tree-multiselect.min.js"></script>
2.包括用于拖放支持的jQuery UI库。
- <script src="//code.jquery.com/ui/1.11.4/jquery-ui.min.js"></script>
3.创建一个多选并使用数据部分来指定每个选项的层次结构。
- <select id="demo" multiple="multiple">
- <option value="one" data-section="top" selected="selected" data-index="3">C++</option>
- <option value="two" data-section="top" selected="selected" data-index="1">Python</option>
- <option value="three" data-section="top" selected="selected" data-index="2">Ruby</option>
- <option value="four" data-section="top">Swift</option>
- <option value="wow" data-section="JavaScript/Library/Popular">jQuery</option>
- </select>
4.初始化插件。
- $("#demo").treeMultiselect(options);
5.可能的插件选项。
- $("#demo").treeMultiselect({
- // Sections have checkboxes which when checked, check everything within them
- allowBatchSelection: true,
- // Selected options can be sorted by dragging
- // Requires jQuery UI
- sortable: false,
- // Adds collapsibility to sections
- collapsible: true,
- // Enables selection of all or no options
- enableSelectAll: false,
- // Only used if enableSelectAll is active
- selectAllText: 'Select All',
- // Only used if enableSelectAll is active
- unselectAllText: 'Unselect All',
- // Disables selection/deselection of options; aka display-only
- freeze: false,
- // Hide the right panel showing all the selected items
- hideSidePanel: false,
- // max amount of selections
- maxSelections: 0,
- // Only sections can be checked, not individual items
- onlyBatchSelection: false,
- // Separator between sections in the select option data-section attribute
- sectionDelimiter: '/',
- // Show section name on the selected items
- showSectionOnSelected: true,
- // Activated only if collapsible is true; sections are collapsed initially
- startCollapsed: false,
- // Allows searching of options
- searchable: false,
- // Set items to be searched. Array must contain 'value', 'text', or 'description', and/or 'section'
- searchParams: ['value', 'text', 'description', 'section'],
- // Callback
- onChange: null
- });
v2.6.3版本(2022-08-24)
v2.6.1版本(2019-04-17)
v2.6.0版本(2019-02-12)
v2.5.2版本(2018-05-04)
v2.5.1版本(2017-12-25)
v2.5.0版本(2017-11-02)
v2.4.3版本(2017-11-02)
v2.4.1版本(2017-10-19)
v2.4.0版本(2017-09-26)
v2.3.0版本(2017-04-29)
v2.2.1版本(2017-04-29)
v2.2.0版本(2017-04-24)
v2.1.6版本(2017-03-31)
v2.1.4版本(2017-03-18)
v2.1.3版本(2017-01-03)
v2.1.2版本(2016年12月26日)
v2.0.2版本(2016年11月23日)
v2.0.0版本(2016-10-30)
v1.18.0(2016年10月19日)
v1.17.2(2016年7月13日)
v1.17.1(2016年6月26日)
v1.17.1(2016年4月16日)
v1.17.0(2016年4月15日)
v1.16.0(2015年12月21日)
v1.15.3(2015年12月18日)
v1.15.2(2015年12月1日)
v1.15.0(2015年11月24日)
v1.15.0(2015年10月27日)
v1.14.4(2015年9月10日)
v1.14.3(2015年8月29日)
v1.14.1(2015年8月29日)
v1.14.0(2015年8月27日)
v1.13.1(2015年8月25日)
v1.13.0(2015年8月23日)