Group, Container or Template Repeater?

What would make the most sense of the three?

I have three templates per grouping and will have 19 of these groupings. Each grouping has a button to toggle a button state within each template, and each template's button can toggle it's own button state.

I found that with Containers I cannot move them like other components, so positioning would be more technical. Other than that, are there any recommendations regarding which Container Type I should use?

Note: only the Grouped objects are tied to tag values and I have little extra styling.

Group:
image

Container:
image

Template Repeater:
image

If you've got 19 identical groups (of 1 button + 3 templates) I'd absolutely package that into a template and use a Template Repeater or Template Canvas to render the 19 instances, no question.

1 Like

I'm playing with something like this:

Parent: Template Repeater.
Each group of three plus the big button is in a Template.
Group of three without the big button are Templates in a Template Repeater.

So, to "navigate" to the individual template: Repeater --> Template--> Repeater --> Template.

Each individual template is an UDT. Is this nesting too much to realistically pass parameters/values to the UDT and retrieve changes made? It seems like a quick way to instantiate a bunch of templates.

Could I do something like this:

repeater = event.source..parent.getComponent('Template Repeater')
for template in repeater.loadedTemplates:
     repeater2 = template.getComponent('Template Repeater 2')
          for template2 in repeater2:
               do something here?

Since the inner repeater is always three, I'd probably just use three instances.

But anyway, Vision doesn't have any significant problem with complex nesting, and there are no barriers to traversing the hierarchy by script any way you need, so carry on.

Well, I'm going to have at least 19 instances, 16 of one template, 3 of another.

I couldn't figure out how to go that deep in the example above, so I built another.

This time: Repeater with a dataset, and each instance is a Template of 3 templates.


Each grouping, including the large button is a template, the internal templates/UDTs are the three "line items".
image

I'm having a hard time wrapping my head around getting to the nested templates/repeaters (in the first post).

repeater = event.source.parent.getComponent('Template Repeater 2')
for template in repeater.loadedTemplates:
	template2 = template.getComponent('Zone_3Pos')
	template2.templateParams['toggle_main'] = 1

The above code presents the error: Nonetype has no attribute: templateParams, which refers to template2 variable.

repeater = event.source.parent.getComponent('Template Repeater 2')
for template in repeater.loadedTemplates:
	arguments = []
	for customProp in template.dynamicProps:
		arguments.append(template.getPropertyValue(customProp))
	print(arguments)

EDIT:
This code prints out 9 values, which appear to be the custom property values of each individual template/UDT and their parent templates. But, I manually counted 10 custom props, instead of 9.

That was wrong... the customProps are from the group template, meaning the second nested template.

Print output:

[0, 0, 0, 0
, UDTProperty[type=_types_/Power_Supply_,path=<null>]
, UDTProperty[type=_types_/Power_Supply_,path=<null>]
, UDTProperty[type=_types_/Power_Supply_,path=<null>]
, 7, u'07']

Can I assign a value to the parameters from here? If so, how do I target a specific one? Like template.templateParams['toggle_main'] = 0?

I think I found something here:

repeater = event.source.parent.getComponent('Template Repeater 2')
templateList = repeater.getLoadedTemplates()
for template in templateList:
	template.dynamicProps['tog_1'].value = 1
	print template.dynamicProps['tog_1'].value

It seems I can write to a specific template parameter with the above code.

BUT, the changes are not reflected in the components that are bound to said parameter, so that tells me I am not really writing to it.

Have you tried this?

template.tog_1 = 1
1 Like

Well then... that is simple and sweet! Thank you, Phil!