# How to use a template repeater in a template

**URL:** <https://forum.inductiveautomation.com/t/how-to-use-a-template-repeater-in-a-template/96475>\
**Category:** Ignition\
**Tags:** vision\
**Created:** [September 26, 2024, 7:56am UTC](https://forum.inductiveautomation.com/t/how-to-use-a-template-repeater-in-a-template/96475 "2024-09-26T07:56:42Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lion\_Sun](https://avatars.discourse-cdn.com/v4/letter/l/3ab097/32.png) [@Lion\_Sun](https://forum.inductiveautomation.com/u/Lion_Sun)\
**Post date:** [September 26, 2024, 7:56am UTC](https://forum.inductiveautomation.com/t/how-to-use-a-template-repeater-in-a-template/96475/1 "2024-09-26T07:56:42Z")

</div>

I want to use a template repeater within a template, which means a nested template. I set the Repeat Behavior as "Dataset", and binding the Template Parameters to a Dataset. I'm not clear on how to construct a Dataset to make this nested templates work well.

Does anyone have any idea or any example to share ?

---

<div class="post-metadata">

**Author:** ![Lion\_Sun](https://avatars.discourse-cdn.com/v4/letter/l/3ab097/32.png) [@Lion\_Sun](https://forum.inductiveautomation.com/u/Lion_Sun)\
**Post date:** [September 26, 2024, 8:19am UTC](https://forum.inductiveautomation.com/t/how-to-use-a-template-repeater-in-a-template/96475/2 "2024-09-26T08:19:02Z")

</div>

I use template and template repeater often. This is first time I try to use a template within a template.

When I create a new vision template, I found it is ok to add a template repeater component in this template, so I think it is feasible to use a template within in a template. but I did not found any examples in Ignition manual or in this forum.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [September 26, 2024, 12:13pm UTC](https://forum.inductiveautomation.com/t/how-to-use-a-template-repeater-in-a-template/96475/3 "2024-09-26T12:13:02Z")

</div>

You will certainly have to programmatically construct the dataset for the inner repeater. Search this forum for `system.dataset.toDataSet` for many, many examples.

---

<div class="post-metadata">

**Author:** ![Lion\_Sun](https://avatars.discourse-cdn.com/v4/letter/l/3ab097/32.png) [@Lion\_Sun](https://forum.inductiveautomation.com/u/Lion_Sun)\
**Post date:** [September 26, 2024, 12:30pm UTC](https://forum.inductiveautomation.com/t/how-to-use-a-template-repeater-in-a-template/96475/4 "2024-09-26T12:30:55Z")

</div>

I'm quite familiar with this system.dateset.toDataSet functions , I can easy construct a dataset for first template, but how to transfer another dataset can be applied to the second template which is nested in first template? one template instance only receice one dataset.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [September 26, 2024, 12:38pm UTC](https://forum.inductiveautomation.com/t/how-to-use-a-template-repeater-in-a-template/96475/5 "2024-09-26T12:38:55Z")

</div>

You cannot nest datasets. You must provide the information in the outer dataset for the template containing the repeater to construct (or indirect bind) the desired inner dataset.

---

<div class="post-metadata">

**Author:** ![Lion\_Sun](https://avatars.discourse-cdn.com/v4/letter/l/3ab097/32.png) [@Lion\_Sun](https://forum.inductiveautomation.com/u/Lion_Sun)\
**Post date:** [September 26, 2024, 3:22pm UTC](https://forum.inductiveautomation.com/t/how-to-use-a-template-repeater-in-a-template/96475/6 "2024-09-26T15:22:51Z")

</div>

I have finally work out this. with nested dateset. Even it works, I still not feel not very clear about it.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [September 26, 2024, 3:25pm UTC](https://forum.inductiveautomation.com/t/how-to-use-a-template-repeater-in-a-template/96475/7 "2024-09-26T15:25:20Z")

</div>

> [@Lion\_Sun](#):
>
> with nested dateset

You mean a dataset in an object column of another dataset? I'll be shocked if this doesn't blow up on serialization.

---

<div class="post-metadata">

**Author:** ![Lion\_Sun](https://avatars.discourse-cdn.com/v4/letter/l/3ab097/32.png) [@Lion\_Sun](https://forum.inductiveautomation.com/u/Lion_Sun)\
**Post date:** [September 26, 2024, 3:33pm UTC](https://forum.inductiveautomation.com/t/how-to-use-a-template-repeater-in-a-template/96475/8 "2024-09-26T15:33:00Z")

</div>

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/9/49ce4a4fbd54793638a6f3988eba5cd459e970f5.jpeg)  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/4/24ac2e4f85f1087ba701c340ac6af7bdced761d5.png)

I construct a dynamic dataset called ‘detail’， just as above example， it is a dataset[3R\*3C], two columns are with dataset in it. the column 'Detail' is used in first template, and the 'InnerDetail' is used in nested template. Finally, it works well.

---

<div class="post-metadata">

**Author:** ![Lion\_Sun](https://avatars.discourse-cdn.com/v4/letter/l/3ab097/32.png) [@Lion\_Sun](https://forum.inductiveautomation.com/u/Lion_Sun)\
**Post date:** [September 26, 2024, 3:54pm UTC](https://forum.inductiveautomation.com/t/how-to-use-a-template-repeater-in-a-template/96475/9 "2024-09-26T15:54:01Z")

</div>

Not dataset in object column, just a dataset which with dataset as cells in it. In template repeater property binding, we can only specify one dataset as template parameter. So I use this method to transfer in more than one datasets.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [September 26, 2024, 3:56pm UTC](https://forum.inductiveautomation.com/t/how-to-use-a-template-repeater-in-a-template/96475/10 "2024-09-26T15:56:39Z")

</div>

This works in the designer, but does it work if you close the window and re-open it? That's the serialization piece Phil (and I) am worried about. The underlying encoding scheme Vision uses is definitely not _designed_ to support putting datasets inside datasets, so if it does work it's only by "accident" and therefore you're in the realm of "undefined behavior".

---

<div class="post-metadata">

**Author:** ![Lion\_Sun](https://avatars.discourse-cdn.com/v4/letter/l/3ab097/32.png) [@Lion\_Sun](https://forum.inductiveautomation.com/u/Lion_Sun)\
**Post date:** [September 26, 2024, 4:28pm UTC](https://forum.inductiveautomation.com/t/how-to-use-a-template-repeater-in-a-template/96475/11 "2024-09-26T16:28:50Z")

</div>

Yes, it also works well when I close in designer and open in vision client. I still not quite understand how to provide information in outer dataset to supply the inner nested template. I will further experiment on it. I think if there is an example demo will be better for understanding.

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [October 15, 2024, 8:26pm UTC](https://forum.inductiveautomation.com/t/how-to-use-a-template-repeater-in-a-template/96475/12 "2024-10-15T20:26:13Z")

</div>

I imagine that this should be done with scripting. The template itself should have a custom property with a name like `parameters`, and the inner template repeater should be bound to it.

Then, from the outer repeater, or by some other means, the datasets should be dynamically created and assigned to the inner templates' custom properties.

**Example:**

```python
# Written for the propertyChange event handler of a template repeater
# That repeats a template with nested repeaters
if event.propertyName == 'componentRunning' and event.newValue:
	# ===============
	# Dynamically create headers and data here for the outer repeater
	# ===============
	event.source.templateParams = system.dataset.toDataSet(headers, data)

# Update the inner repeaters here
elif event.propertyName == 'templateParams':
	
	def loadInnerParameters():
		for template in event.source.loadedTemplates:
			# ===============
			# Dynamically create the headers and data for the inner repeaters here, 
			# ...and assign them to the custom properties
			# ===============
			template.parameters = system.dataset.toDataSet(headers, data)
	
	# Wait some arbitrary amount of time [half a second]
	# ...to give the templates time to load
	system.util.invokeLater(loadInnerParameters, 500)

```
