Chosen options, in particular options grouped using optgroup

Chosen options, in particular options grouped using optgroup

chopstikchopstik Posts: 14Questions: 5Answers: 0

Is it possible at all to prrovide an object containing groups of [label/values] to the Chosen editor plugin that would pass on those groupings of options to Chosen to enable it to present/display select options surrounded by the orthodox <optgroup>?

https://editor.datatables.net/plug-ins/field-type/editor.chosen

Answers

  • allanallan Posts: 61,972Questions: 1Answers: 10,160 Site admin

    Hi,

    I'm sorry to say that this is not something that is currently possible via the Editor API. If they had an API to be able to do it, then it would be possible via that, but I don't see such an API I'm afraid.

    Allan

  • chopstikchopstik Posts: 14Questions: 5Answers: 0

    Why would we need an API to make that happen? If we passed well formed, semantic <option> + <optgroup> to Chosen it would render as required surely?

  • allanallan Posts: 61,972Questions: 1Answers: 10,160 Site admin

    Because it isn't creating options that way. Its using Javascript's Option object. Line 38 here:

    elOpts[i] = new Option( label, val );
    

    That could be modified to allow for optgroups to also be created, but Editor's pair's method doesn't currently allow for that. If you know what your JSON structure is though, then that might be enough.

    Allan

This discussion has been closed.