【发布时间】:2018-10-12 18:09:16
【问题描述】:
我已经成功使用 dataTables+yacdf+select2 组合有一段时间了。现在我正在努力将我的 select2 转换为一个有序的缩进下拉列表,其中 optgroup 也可选择(https://select2.org/options,“分层选项”,Selectable optgroups in Select2)。
但是,使用 yacdf,我似乎无法以如下所示的分层格式将数据传递给 select2:
var data = [
{
"text": "Group 1",
"children" : [
{
"id": 1,
"text": "Option 1.1"
},
{
"id": 2,
"text": "Option 1.2"
}
]
},
{
"text": "Group 2",
"children" : [
{
"id": 3,
"text": "Option 2.1"
},
{
"id": 4,
"text": "Option 2.2"
}
]
}];
以前的工作代码是:
.yadcf([{column_number: 1, filter_type: "multi_select", select_type: 'select2', filter_container_id: "someFilter2", filter_default_label: "Select xxx", filter_reset_button_text: false, style_class: "form-control",
select_type_options: {
multiple: 'multiple',
width: '100%',
placeholder: 'something',
},
data: [<comma separated list of values>]
yacdf 源代码指出:
Required: false
Type: Array (of string or objects)
Description: When the need of predefined data for filter is needed just use an array of strings ["value1","value2"....] (supported in select / multi_select / auto_complete filters) or array of objects [{value: 'Some Data 1', label: 'One'}, {value: 'Some Data 3', label: 'Three'}] (supported in select / multi_select filters)
注意:当 filter_type 为 custom_func / multi_select_custom_func 时,此数组将填充自定义过滤器选择元素 "
真的不可能吗? 如果没有人设法让嵌套的下拉过滤器以其他方式与 dataTables 一起使用?
【问题讨论】:
标签: datatables jquery-select2 yadcf