More checkbox editor examples for trial evaluation purposes
More checkbox editor examples for trial evaluation purposes
I started evaluating editor for a small requirement I have but I am not so sure it can be done without changing the underlying data structure
This example https://editor.datatables.net/examples/advanced/joinArray.html is closest to what I am looking for
User selects the row, clicks edit and can checkbox up to 3 options Email, SMS, Call
What is displayed however is based on the enabled field in the JSON
DataTables table is able to render the column correctly with simple { data: "notification.enabled" }
The editor however will not render the checkboxes with the editor fields initialization options below.
Any ideas if this is supported in datatables editor ?
{
label: "Notification:",
name: "notification.options",
type: "checkbox"
},
//Data source
[
{
"notification": {
"enabled": ["Email"],
"options": ["Email", "SMS", "Call"]
},
"_id": "5c2bab964d83ef7b06599621",
"name": "Doyle Gerlach IV"
}, {
"notification": {
"enabled": ["Email"],
"options": ["Email", "SMS", "Call"]
},
"_id": "5c2bab964d83ef7b06599620",
"name": "Keagan Batz"
}
]
Answers
Can the options be different for each row? If so you'd need to update the list of options available as each row is edited - that could be done with
initEdit
and thefield().update()
method ofselect
.For example:
Allan
Options will be identical for each row. Enabled will always be a subset.
Field below does not render the checkbox. It is not clear from examples if anything extra is needed.
DataTables wise however the column is being rendered correctly with
You need to set the options for the field using the
field().update()
method like I suggested above. If the options are static, then you could simply use:Note also that since you want to edit the value of the
enabled
array, you should use:in your Editor field definition.
Allan
This is brilliant. So probably means notification.options isnt even needed. Many thanks
Curious if you have a roadmap for editor published somewhere ? Would be keen to look at upcoming features and if there are plans to loose jquery as a dependancy