Variable number of columns

Variable number of columns


Is there any pattern for creating a table records widget with a dynamic number of columns?

Thank you,

Unfortunately, I came across this same problem some time ago, and found that it's not possible within Service Studio to do it, unless you have an upper bound to the number of columns. If is this the case (or you find reasonable to assume an upper bound), you can assign the style="display:none" extended property to all cells which are not to be displayed.

For the general case, your work-around currently is to construct the table in HTML to a text variable, and then use an unescaped expression to display it. If you need any help, I can provide you a sample.

Best Regards,
Leonardo Fernandes
Hi all,

Since version 6.0 that it is possible to add web blocks inside TableRecords and ListRecords widgets. This makes it possible to create UI iterators inside these widgets and, therefore, making this pattern of a variable column table a lot easier to implement.

To achieve the following:

Record Record A Record B Record C
Record 1 A.1 B.1 C.1
Record 2 A.2 B.2 C.2
Record 3 A.3 B.3 C.3

In broad strokes this is what you do:
  1. Add a TableRecords to your page with 2 columns
  2. Bind it to a query over the entity that returns Record 1,2 and 3.
  3. The first column will be the label (or other identifying attribute) of that entity
  4. The second column will be filled in with two web blocks, one in the header and another in the body.
  5. The header web block will have a list records the createas a column for each Record A, B and C
  6. The body we block will have the values for the relation entity that relates A with 1, B with 2 and C with 3
I know this can be confusing... See the attached sample to see this pattern implemented. Here's an image of the end result: