1

I have a CFSELECT tag as below but it doesn't create the <optgroup> tags. How can I archive this?

<cfselect name="name" value="DB_ID" group="DB_Grouping"
display="DB_Description" selected="#Selected_ID#"
bind="cfc:[path_to_CFC]" bindOnLoad="true" style="width:305px;" />

The dropdown loads like this:

<select id="name" name="name">
    <option value="DB_ID_1">DB_Description_1</option>
    <option value="DB_ID_2">DB_Description_2</option>
    <option value="DB_ID_3">DB_Description_3</option>
    <option value="DB_ID_4">DB_Description_4</option>
</select>

instead of:

<select id="name" name="name">
    <optgroup label="DB_Grouping_1">
        <option value="DB_ID_1">DB_Description_1</option>
        <option value="DB_ID_2">DB_Description_2</option>
    </optgroup>
    <optgroup label="DB_Grouping_2">
        <option value="DB_ID_3">DB_Description_3</option>
        <option value="DB_ID_4">DB_Description_4</option>
    </optgroup> 
</select>

Can anyone please help?

Leigh
  • 28,765
  • 10
  • 55
  • 103
RealSollyM
  • 1,530
  • 1
  • 22
  • 35

1 Answers1

2

You may not like it but the best answer is don't use cfselect. Just use a regular HTML select and use jquery to load the data and build the options and groups. This is why the CF UI stuff should be avoided. As soon as you need to do something slightly outside the norm it makes it too difficult. You'll be better off in the long run because you'll know how to roll your own Ajax requests and build the JavaScript to output the options and you won't be stuck with adobe's way of doing it.

Sean Coyne
  • 3,864
  • 21
  • 24
  • 1
    I don't know if I should mark this as an accepted answer or not, because it's not really answering the question but giving a different, totally different, approach on trying to resolve the issue. Saying it make it too difficult suggest that it's possible - my question then is how do I make it that way? Although the CF site is currently our main website, we are working on moving it to .NET and therefore cannot change most of the processes in place for a simple drop down. For now I have implemented ``. It's not the best. – RealSollyM Jul 21 '14 at 11:18
  • 2
    Bind does not support grouping. The CF UI tags are limiting. Just because you are using CF doesn't mean you have to use them. You are using HTML first and foremost. So do it the right way and build it yourself. You don't have to accept my answer but it's not going to work the way you want it to with just cfselect. – Sean Coyne Jul 21 '14 at 11:46
  • I think the comment made it worth a vote. At least the next person who will read the response will also know that it's not worth going that route. – RealSollyM Jul 21 '14 at 11:48