Can you use the optgroup tag in a drop-down list

Duncan Koza asked on February 12, 2020 18:48

I've created a custom table and a page type in Kentico 11. The page type has a 'Drop-down list' form control. The form control is using an SQL Query to pull the data from the custom table.

My question is: Can the form control handle <optgroup> tags or am I limited to only doing simple <option> tags within the rendered out <select> tag.

Example:

<select class="form-control">
    <option value="0">-- Please Select a Site --</option>
    <option value="980">All Pictures</option>
    <option value="981">All Colours</option>
    <option value="982">All Lines</option>
    <optgroup label="Pictures">
        <option value="1">Pets</option>
        <option value="2">People</option>
        <option value="3">Buildings</option>
    </optgroup>
    <optgroup label="Colours">
        <option value="14">Red</option>
        <option value="23">Green</option>
        <option value="22">Blue</option>
    </optgroup>
    <optgroup label="Lines">
        <option value="11">Solid</option>
        <option value="12">Dashed</option>
        <option value="10">wavy</option>
        <option value="24">dots</option>
    </optgroup>
</select>

Thank you

Recent Answers


Dat Nguyen answered on February 13, 2020 12:21

I don't believe any built-in dropdown form control supports optgroup, but you can develop your own custom form control.

1 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.