Dynamic number of tables

May I ask for idea. my template have 2 table type.

  1. Dynamic table (Green), can done by tool. This is no problem.
  2. Dynamic number of tables (Red), I have only one idea to use javascript to loop “S” length then write html.

from 2. Dynamic number of tables, do you have any other idea to achieve this requirement?
I am not sure maybe ol have some tools or some way to achieve this without script.

Which version of OL Connect have you installed currently? The reason why I am asking is because using Handlebars to achieve this sounds the way to go.

The following example will create a new HTML table for each record in the detail table “S”.

Example

{{#each S}}
<table class="table--grid" cellpadding="0" cellspacing="0" style="width: 100%;">
	<thead>
		<tr>
			<th style="width: 25%;">1</th>
			<th style="width: 25%;">2</th>
			<th style="width: 25%;">3</th>
			<th style="width: 25%;">4</th>
		</tr>
	</thead>
	<tbody>
		<tr>
			<td>A</td>
			<td>{{COLUMN3}}</td>
			<td>{{COLUMN8}}</td>
			<td></td>
		</tr>
		<tr>
			<td>B</td>
			<td>{{COLUMN4}}</td>
			<td>{{COLUMN9}}</td>
			<td></td>
		</tr>
		<tr>
			<td>C</td>
			<td>{{COLUMN5}}</td>
			<td>{{COLUMN10}}</td>
			<td></td>
		</tr>
	</tbody>
</table>
{{/each}}

Here is an example templates with two approaches, both using Handlebars snippets. The first section uses the partial helper and the second uses a script to load the snippet.

The repeat logic is in the Handlebars snippet as suggested by @Marten

Hope this helps,

Erik

See: Partials

ruppawat.OL-datamapper (4.7 KB)
ruppawat.OL-template (10.7 KB)

Hi Erik & Marten
Thank you so much for your help.

1 Like