我正在尝试在数据表编辑器中实现多选下拉列表。 但无法弄清楚如何通过选项。我正在使用select2插件。 (https://editor.datatables.net/plug-ins/field-type/editor.select2)
示例代码:
var opts = {
"multiple": true,
"placeholder": "Select Device Types"
}
var choice = [
{ label: "Oil", value: "Oil" },
{ label: "2", value: "2" },
{ label: "3", value: "3" },
{ label: "4", value: "4" },
{ label: "5 (lowest)", value: "5" }
]
var editor
function plot_table(){
editor= new $.fn.dataTable.Editor( {
data:[{'employee_name': "jijo"}],
"table": "#emp_hierarchy_table",
"fields": [{'name': 'employee_name', 'label': 'Emp Name', 'type':'select2','options': choice ,'opts':opts}]
} );
$('#emp_hierarchy_table').on( 'click', 'tbody td:not(:first-child)', function (e) {
editor.inline( this );
} );
$('#emp_hierarchy_table').DataTable( {
dom: "Bfrtip",
data:[{'employee_name': "jijo"}],
"ordering": false,
columns: [{'data': 'employee_name', 'title': 'employee_name'}],
buttons: [ { extend: "create", editor: editor }],
} );
}
这是我得到的输出。 https://i.stack.imgur.com/T7GZQ.png