How to create a table with variable number of columns

How to create a table with variable number of columns


I need to create a table where the row and column names are taken from SQL tables with a variable number of records. The cells of the table will have checkboxes, so in fact the user will be choosing which row/column combinations he wants to use.

For example, I may have columns A, B, C, D and rows 1, 2, 3.
If the user wants to use combinations A1 and C3, he will check those combinations on the table.

Next time, however, he could have columns A, B, C and rows 1,2,3, 4. The values to be used are taken from SQL tables, so they may vary each time the screen is loaded.

There is no problem with the rows, of course, but I need to be able to define the number of columns dynamically.

Any ideas?

Thanks a lot for your help.

Henrique Capela

You may construct the dynamic html and then put it in an expression with Escape Content = No. For example pseudo code for dynamic columns:

OuterHtml = "<table><tr>"
ASSIGN InnerHtml = InnerHtml + "<td> another column </td>"
OuterHtml = OuterHtml + InnerHtml + "</tr>/table"

Now you just put an expression of OuterHTML variable with EscapeContent=No.
You may have to deal with style classes on the <td>'s . You can have a boolean indicating if this is an alternate row and then apply the correct class.

Thanks, I'll try that out.

Henrique Capela