Template repeater dataset

Is it possible to create the Template Repeater dataset via a script at runtime?

I’m going to be showing a variable number the templates based on a numerical textbox. I need to use the dataset type as I have two custom properties that I need to assign.

I’ve tried to pull the dataset out and add rows using the system but the new template doesn’t show up in the repeater.

This is my testing code that I’m using to try and get it done:

numInterlocks = event.source.parent.getComponent('numInterlocks').intValue

tempRepeater = event.source.parent.getComponent('interlockRepeater').templateParams

for interlock in range(numInterlocks):
	print 'Doing interlock ' + str(interlock)
	newRow = [interlock,'Standards/C100/Intlk']
event.source.parent.getComponent('interlockRepeater').templateParams = tempRepeater

I don’t get any errors… just the “Doing interlock 0” -> 4.

Any ideas? Is what I’m trying to do possible?

system.dataset.addRow(tempRepeater,newRow) - the system.dataset calls return a modified dataset (rather than modifying the dataset in place, since datasets are immutable).

Assign the return value to a variable throughout the loop, then assign it back to the component when the loop finishes:

tempRepeater = event.source.parent.getComponent('interlockRepeater')
updatedParams = tempRepeater.templateParams

for interlock in range(numInterlocks):
	print 'Doing interlock ' + str(interlock)
	newRow = [interlock, 'Standards/C100/Intlk']
	updatedParams = system.dataset.addRow(updatedParams, newRow)
tempRepeater.templateParams = updatedParams

Thanks so much for the help. That worked perfectly.

1 Like