# Refresh Template Repeater data from a template inside of the repeater

**URL:** <https://forum.inductiveautomation.com/t/refresh-template-repeater-data-from-a-template-inside-of-the-repeater/18176>\
**Category:** Ignition\
**Tags:** ignition79, scripting\
**Created:** [May 25, 2018, 10:21pm UTC](https://forum.inductiveautomation.com/t/refresh-template-repeater-data-from-a-template-inside-of-the-repeater/18176 "2018-05-25T22:21:02Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Stuart](https://avatars.discourse-cdn.com/v4/letter/s/cab0a1/32.png) [@Stuart](https://forum.inductiveautomation.com/u/Stuart)\
**Post date:** [May 25, 2018, 10:21pm UTC](https://forum.inductiveautomation.com/t/refresh-template-repeater-data-from-a-template-inside-of-the-repeater/18176/1 "2018-05-25T22:21:02Z")

</div>

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.

```auto
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.

---

<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:** [May 26, 2018, 6:20am UTC](https://forum.inductiveautomation.com/t/refresh-template-repeater-data-from-a-template-inside-of-the-repeater/18176/2 "2018-05-26T06:20:52Z")

</div>

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.)

---

<div class="post-metadata">

**Author:** ![Stuart](https://avatars.discourse-cdn.com/v4/letter/s/cab0a1/32.png) [@Stuart](https://forum.inductiveautomation.com/u/Stuart)\
**Post date:** [May 26, 2018, 10:24pm UTC](https://forum.inductiveautomation.com/t/refresh-template-repeater-data-from-a-template-inside-of-the-repeater/18176/3 "2018-05-26T22:24:29Z")

</div>

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 `parent`s? I would have expected 2 - the first to get to the Template, and the second to get to the Template Repeater - rather than 5.

---

<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:** [May 27, 2018, 12:44pm UTC](https://forum.inductiveautomation.com/t/refresh-template-repeater-data-from-a-template-inside-of-the-repeater/18176/4 "2018-05-27T12:44:00Z")

</div>

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 inspect.py](https://www.automation-pros.com/ignition/inspect.py) on each layer for more details. See also the shared.inspect.holder() function usable in client/designer scopes.

---

<div class="post-metadata">

**Author:** ![Luke\_Marcus](https://avatars.discourse-cdn.com/v4/letter/l/85f322/32.png) [@Luke\_Marcus](https://forum.inductiveautomation.com/u/Luke_Marcus)\
**Post date:** [December 5, 2023, 4:22pm UTC](https://forum.inductiveautomation.com/t/refresh-template-repeater-data-from-a-template-inside-of-the-repeater/18176/5 "2023-12-05T16:22:08Z")

</div>

Is there a way to reference a custom method on the template by using a button that is on the same vision window as the template/template repeater?

For context:  
I'm attempting to create a Refresh button on a window that also has a template repeater that targets two tables on this template with separate databases associated with each that I would like to refresh.

---

<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:** [December 5, 2023, 5:02pm UTC](https://forum.inductiveautomation.com/t/refresh-template-repeater-data-from-a-template-inside-of-the-repeater/18176/6 "2023-12-05T17:02:17Z")

</div>

You'll have to explore the Swing component hierarchy with `.getComponent(int)`. However, you will likely be unable to call the custom method on the retrieved Swing components unless you have my Integration Toolkit module installed (formerly known as Simulation Aids), due to limitations of Ignition's native PyComponentWrapper callsites. See this topic for skull-cracking details:

> [@Transaction groups triggered expression item updating when trigger is false](https://forum.inductiveautomation.com/t/transaction-groups-triggered-expression-item-updating-when-trigger-is-false/17196/14):
>
> Ok, so I’ve been down the rabbit hole and found Ignition’s (undocumented) PyComponentWrapper. I haven’t deciphered it enough to be sure, but it seems to be invoked only for particular situations, based on the string constants in the class file (like “getComponent” and “getComponents”). To play with this, I constructed a conversion adapter like so: public class PyComponentAdapter implements PyObjectAdapter { public PyComponentAdapter() {} @Override public boolean canAdapt(Object jObj) { …

---

<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:** [December 10, 2023, 3:11pm UTC](https://forum.inductiveautomation.com/t/refresh-template-repeater-data-from-a-template-inside-of-the-repeater/18176/7 "2023-12-10T15:11:40Z")

</div>

> [@Luke\_Marcus](#):
>
> Is there a way to reference a custom method on the template by using a button that is on the same vision window as the template/template repeater?

I did a quick experiment, and this worked on a test template with a custom method that was being rendered by a template repeater:

```auto
# Get the loaded templates from the template repeater
templates = event.source.parent.getComponent('Template Repeater').loadedTemplates

# Iterate through them, and call their custom methods
for template in templates:
	template.testMethod()

```

I usually don't run into the missing PyComponentWrapper unless I access the component using SwingUtilities. On systems that do not have the Integration Toolkit, the wrapper can be put back on the component in this way:

```auto
# Import the class that wraps Vision components
from com.inductiveautomation.factorypmi.application.script import PyComponentWrapper

# Get the component in a way that causes it to lose its wrapper \o/
unwrappedComponent = # However you get your component

# Pass the unwrapped component into the PyComponentWrapper,
# ...and it will return the component properly wrapped
wrappedComponent = PyComponentWrapper(unwrappedComponent)

```
