I am trying to implement multi-select dropdown in the data table editor. But not able to figure out how to pass the options. I am using the select2 plugin. (https://editor.datatables.net/plug-ins/field-type/editor.select2)
Sample Code:
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 }],
} );
}
This is the output that I am getting. https://i.stack.imgur.com/T7GZQ.png