Refresh Template Repeater data from a template inside of the repeater

I have a Template Repeater I am using to show some templates. Each template has a button that can be pressed to change the order of the templates in the repeater.

Right now the changes are saved to the database, but the only way I can get the template repeater to reflect the changes is to close/open the template window, or to click a button on the same page as the Template Repeater to manually refresh it.

Here is the script I am using. Pretty simple.

TemplateRepeater = event.source.parent.getComponent('Template Repeater')
system.db.refresh (TemplateRepeater, "templateParams")
  • Is there a way I can run this script from a template inside of the repeater?
  • I’m sort of assuming there is not. Could I put a custom property on the Template Repeater that would refresh it’self if a certain value changed on one of the templates?
  • Any other options?

Thanks for the help.

Place your system.db.refresh in a custom method on the repeater. Then within the template, use event.source.parent.parent.customMethod(). (Might need more 'parent’s in there, depending on the depth of your code.)

Thanks! I put the button directly on the template, and then was able to access it by putting event.source.parent.parent.parent.parent.parent.customMethod() on the actionPerformed of the button.

Any idea why it required so many parents? I would have expected 2 - the first to get to the Template, and the second to get to the Template Repeater - rather than 5.

There’s a scrolling view layer and it’s inner window (allowing for scroll bars), plus one more for the template holder analog just below the template root. I think. You can use shared.inspect.introspect() from on each layer for more details. See also the shared.inspect.holder() function usable in client/designer scopes.

1 Like