Editors Select2
Editors Select2
ZakInterDev
Posts: 51Questions: 16Answers: 0
in Editor
Does DataTables/Editor support the grouping option for select2? For example when sending data back using options (see code below) or updating the list after the dependent() method has been called? I'm trying to achieve a header in my select2 list of a branch name, then all the cylinders that belong to that branch. Any ideas?
->options(function() {
$out = array();
foreach ($cylinders as $cylinder) {
$out[] = array("value" => $cylinder->id, "label" => $cylinder->barcode);
}
return $out;
})
Thanks in advance
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Hi,
Not using the built in
update
method of the field type, which supports only a simple list, but I found this SO discussion which shows the data structure that Select2 uses for opt groups and you could set that against the instance manually rather than having Editor do it.Regards,
Allan
So just for anyone coming across this thread. This is the solution, in terms of the link Allan posted.
Just need to figure out an easy way to get the same format sent back from an aJax request.
Thanks once again Allan. Loving DataTables & Editor..using them on a new website we're developing.
Thanks for posting back with your solution. And great to hear it is going well!
Allan