Question

I am trying to use a optgroup tag in CCS. But the default list box doesn't have an option for this. Can someone explain how to get the recordset in After Execute Event and do a custom select HTML using PHP and put in place of the existing select code?

Was it helpful?

Solution

As you found out, the optgroup is not handled in CCS, so you are left with some overriding to do - or do what I did, and decide that optgroup wasn't worth the hassle.

You can use the Listbox Before Show (instead of 'After Execute') method to override/set up the options and use some of the supplied examples as a guide.

Check the help file for the following sections:

  1. 'Dynamically Modify the "List Of Values" of a ListBox'
  2. 'Retrieve Multiple Field Values from a Database'

There are also some partial solutions on the codecharge forums for overriding the options (search for optgroup)

Alternatively, you could consider 2 dependent drop-downs - the 'parent' with the Groups, and the 'child' with the options.

Edit: Modify SQL for listbox

You can do some pretty complex SQL in the Listbox Properties 'Data Source' (use 'Data Source Type' of 'SQL' and enter your SQL in the Query builder) As long as you return at least one column, it will be shown in the 'Bound Column' and 'Text Column' properties of the Listbox.

I'm confused why you reference the 'Before Build' events - you don't need to alter the code there - just use the Properties of the controls. For most of the setup of forms and controls, data etc, it can be done though the Properties and Events, without the need for modifying the generated code (once edited, it won't be regenerated if you change something so then you have code not updating and getting out of sync with the 'design' view)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top