CodeCharge Studio
search Register Login  

Visual Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> Java

 Modify the description of a multi-checkbox list

Print topic Send  topic

Author Message
Tom
Posted: 01/18/2006, 9:07 AM

How can I access and modify the description value of a multi-checkbox list in a before show event, when the values of the multi-select come from the database?
Tom
Posted: 01/18/2006, 2:35 PM

Figured it out. Maybe this will be useful for someone else.
I wanted to put my checkbox list in a table and do a new row for every 4 checkbox elements. The only way I could find to do that is if I decorated the checkbox {Description} with html. Adding "</td>" to every description, but every 4th description I would add "</td></tr><tr>" which would create a new row. And of course, if its the last checkbox, only add "</td>" even if it is divisable by 4.

One of the tricky things going on here is, taking the CheckBoxList options which came from the database, modifying the strings, then create a string that can be used in the setListOfValues method.

I did this because I couldn't find a way to directly modify the description in the CheckBoxList object. If it is possible to do so, I'm still interested in knowing how.
Here is the checkbox list html
  
<tr class="Controls">  
              <td colspan="2">  
                <table>  
                  <tr>  
                    <!-- BEGIN CheckBoxList tc_projects -->  
                    <td><input type="checkbox" value="{Value}" name="{tc_projects_Name}" {Check}>{Description}<!-- END CheckBoxList tc_projects -->  
                  </tr>  
                </table>  
              </td>  
            </tr>  

Here is the Before Show event of the checkbox
  
Enumeration enum_tc_projects = ((CheckBoxList)e.getControl()).getFormattedOptions();  
StringBuffer sb = new StringBuffer();  
Integer optionnum = 0;  
while ( enum_tc_projects.hasMoreElements() )   
{  
	String[] option = (String[]) enum_tc_projects.nextElement();  
	optionnum++;  
    if(enum_tc_projects.hasMoreElements() && optionnum%4 == 0)  
	{  
		option[1] = option[1] + "</td></tr><tr>";  
	}  
	else  
	{  
		option[1] = option[1] + "</td>";  
	}  
	sb.append(option[0]).append(';').append(option[1]).append(';');  
}  
sb.deleteCharAt(sb.length()-1);  
((CheckBoxList)e.getControl()).setListOfValues(sb.toString());  

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.