Template Repeater Folders

Hi everyone,

Got another question. I have two template repeaters set to the “count” repeat behavior. The templates inside are bound indirectly to tags. I would like to point each of the repeaters to a different folder, but can’t figure out how I would get the tag path from the template repeater to the bindings on the templates inside of it.

There may not be a solution, but does anyone have any ideas?

Thanks,

  • Mike
1 Like

The canonical way to do this is to have a template parameter named ‘folder’, and a setting for that in your template repeater’s ‘Template Parameters’ dataset. If your scripts inside the template actually need to access the template repeater component, you could use something like this:[code]from javax.swing import SwingUtilities
from com.inductiveautomation.factorypmi.application.components import TemplateCanvas, TemplateRepeater
from com.inductiveautomation.factorypmi.application.components.template import TemplateHolder

def holder(comp):
for x in (TemplateCanvas, TemplateRepeater, TemplateHolder):
try:
holder = SwingUtilities.getAncestorOfClass(x, comp)
except:
holder = None
if holder:
return holder
return None[/code]Pass ‘event.source’ to this holder() function. Or if you need this in a bound expression, pass ‘binding.target’ within the objectScript() expression function.

Thanks. The issue is that I’d like to use the template repeater in “Count” repeat behavior as opposed to the “Dataset” repeat behavior, so I’m not sure how I can pass parameters to the template…

Ah, then use the ‘index parameter name’ in the repeater. The template must have a template parameter of that name, as an integer. Use that parameter inside the template to construct your indirect tag path.