How to disable the Dropdown options in DataTable Editor?
How to disable the Dropdown options in DataTable Editor?
AJ31
Posts: 4Questions: 3Answers: 0
var editor;
$(document).ready(function() {
editor = new $.fn.dataTable.Editor( {
ajax: "../php/data.php",
table: "#example",
fields: [ {
label: "User:",
name: "user"
}, {
label: "User Data:",
name: "selections",
type: "select",
options: [
{ label: "abc", value: "abc" },
{ label: "xyz", value: "xyz" },
{ label: "pqr", value: "pqr" },
{ label: "def", value: "def" },
{ label: "lmn", value: "lmn" }
]
}
]
});
});
I have the DataTable editor defined as shown in the above code snippet. Under the fields, I want to disable the 'xyz' and 'def'
select options for the User Data label.I tried adding {label: "xyz", value: "xyz", "disabled": true}
but that didn't work for me.
Is there any other option to do that?How do I achieve this?
Answers
You'll need to use the
field().input()
method to get a reference to theselect
and then manipulate its options as required - e.g.:This is required as there isn't currently an option to specify the disabled state through the
options
parameter for the field.Allan