# Trigger a refreshBinding('props.data') from inside the module

**URL:** <https://forum.inductiveautomation.com/t/trigger-a-refreshbinding-props-data-from-inside-the-module/51687>\
**Category:** Module Development\
**Tags:** perspective\
**Created:** [October 7, 2021, 7:44am UTC](https://forum.inductiveautomation.com/t/trigger-a-refreshbinding-props-data-from-inside-the-module/51687 "2021-10-07T07:44:33Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [October 7, 2021, 7:44am UTC](https://forum.inductiveautomation.com/t/trigger-a-refreshbinding-props-data-from-inside-the-module/51687/1 "2021-10-07T07:44:33Z")

</div>

Hello again,

Is there a way to trigger a this.refreshBinding(‘props.data’) (or something similar) from inside the module?  
I would like to implement some sort of refresh button inside my table module. Im guessing its not to hard to trigger a tree.read() through an event, but i doubt this refreshes the binding in ignition…  
I would also have to check if there even is a binding on the property i suppose.

---

<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:** [October 7, 2021, 11:28am UTC](https://forum.inductiveautomation.com/t/trigger-a-refreshbinding-props-data-from-inside-the-module/51687/2 "2021-10-07T11:28:53Z")

</div>

Sounds to me you are making your module too specific to a particular UI. That sounds like something you should expose for scripting (methods to call, and event actions for user responses). Let the user tie things together with the designer as they see fit (possibly interposing more actions that just a refresh).

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [October 7, 2021, 11:45am UTC](https://forum.inductiveautomation.com/t/trigger-a-refreshbinding-props-data-from-inside-the-module/51687/3 "2021-10-07T11:45:33Z")

</div>

yes kinda, but i can use an extension function in order to overwrite the "refresh" if its required.  
But (unfortunalty) extension function are by default disabled so i need to do something else if its not enabled.

Its quite the complex component with tons of features xd And a refresh button is something that sounds usefull all the time so i would like to not have to bind a button or timer on every table i use xd  
i can easily put it in the context menu that shouldnt really mess with any UI.

here i explained a tiny bit and have some screens of what my component all can do so far

> [@Any way to write to a file on the gateway or to database from javascript?](https://forum.inductiveautomation.com/t/any-way-to-write-to-a-file-on-the-gateway-or-to-database-from-javascript/51442/16):
>
> im making quite the complex table component xD… Where its possible to group/filter/rearrange column and rows in the clients browser. And to save these layout states and apply the one you want, for now i save it in a db using some bindings, but now im trying to make it so it can work without having to use bindings/external code. (both chart and table are one and the same component, chart can be opened by a context menu on right click) [image] And yeah i guess that is possible, But i …

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [October 8, 2021, 11:23am UTC](https://forum.inductiveautomation.com/t/trigger-a-refreshbinding-props-data-from-inside-the-module/51687/4 "2021-10-08T11:23:05Z")

</div>

@paul-griffith any idea?

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [October 8, 2021, 3:38pm UTC](https://forum.inductiveautomation.com/t/trigger-a-refreshbinding-props-data-from-inside-the-module/51687/5 "2021-10-08T15:38:55Z")

</div>

I don’t really understand why you’d want to trigger a specific binding from the backend.

It seems like your component is trying to do a bit too much at one time. Again, I still don’t really understand all of what you’re trying to get to, but it seems like you want the data to be totally dynamic. That’s a laudable goal, but if that’s the case, then it’s a bit of an anti-pattern to programmatically refresh it. You _may_ know better than your users when to refresh, but usually we try to make ‘display’ components (table, standard charts, dropdowns, etc) data-agnostic, so to speak. They ‘just’ display whatever data they’re fed from their own bindings, and it’s up to the designer to add in programmatic refreshes.

On the other end of things, you’ve got ‘bespoke’ components, like the alarm status table. Here, you’re _by definition_ always going to be querying one specific area - so you just expose your filters and tuning knobs and whatever else to the user via properties.

It seems like you’re trying to make a component that’s data-agnostic, but also “knows” when to refresh itself, which seems like a contradiction to me.

I don’t really _know_ what you’re trying to do, so I’m not trying to say that there’s no way what you’re doing makes sense - you know your problem better than I do, obviously. But I do wonder if there’s not a better way, from ‘first principles’, to set up this component.

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [October 11, 2021, 8:48am UTC](https://forum.inductiveautomation.com/t/trigger-a-refreshbinding-props-data-from-inside-the-module/51687/6 "2021-10-11T08:48:51Z")

</div>

Yes i understand. But some of our tables have quite big querries, so we dont want to refresh them automatically to often through the binding.  
But if they know something new came in, that they need to check right now it could be nice to have the refresh button handy.  
And ofc the designer can do that on the view itself, but we use this component in a lot of views, and I thought its a usefull enough feature to just include in the modules custom context menu.

Are there better ways? maybe, but i havent really thought about it, as this one seemed good enough at the time.

---

<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:** [October 11, 2021, 10:20am UTC](https://forum.inductiveautomation.com/t/trigger-a-refreshbinding-props-data-from-inside-the-module/51687/7 "2021-10-11T10:20:33Z")

</div>

I can’t see building the query into the module, either, unless its the module’s reason for existence. (For a single module, try to do _one_ thing well. Or a group of closely related things.) Let the designer tie stuff together with platform-standard techniques.

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [October 11, 2021, 10:33am UTC](https://forum.inductiveautomation.com/t/trigger-a-refreshbinding-props-data-from-inside-the-module/51687/8 "2021-10-11T10:33:02Z")

</div>

im not building the query in the module. the query is bound to a property “data” just like normal.  
it is this binding i want to refresh tho.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [October 11, 2021, 2:15pm UTC](https://forum.inductiveautomation.com/t/trigger-a-refreshbinding-props-data-from-inside-the-module/51687/9 "2021-10-11T14:15:49Z")

</div>

Well, under the assumption you know better than us :), the good news is it appears to be pretty trivial to trigger a `refreshBinding` yourself:

```java
var property = PropertyKey.fromString(propertyStr);
var result = component.getSession().queue().runOrSubmit(() -> component.refreshBinding(property));

```

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [October 11, 2021, 2:36pm UTC](https://forum.inductiveautomation.com/t/trigger-a-refreshbinding-props-data-from-inside-the-module/51687/10 "2021-10-11T14:36:09Z")

</div>

> [@paul-griffith](#):
>
> under the assumption you know better than us :),

Nah i definitly dont, i dont even know what the words "data-agnostic" and "bespoke" mean xD.  
So i'll add in a prop to turn off this feature by default, that way if someone wants to turn it on they can.

i'll test it out once i have some time, im glad it looks quite easy to do.

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [October 12, 2021, 11:20am UTC](https://forum.inductiveautomation.com/t/trigger-a-refreshbinding-props-data-from-inside-the-module/51687/11 "2021-10-12T11:20:06Z")

</div>

> [@paul-griffith](#):
>
> `() -> component.refreshBinding(property)`

Seems its not as easy afterall xd component.refreshBinding(property) does not work.  
The refreshBinding seems to be located in class ComponentModel, while the component in the delegate is just Component.  
Is it possible to get the ComponentModel ?

Weird there is no findComponentByAddressPath as you can get the AddressPath on both Component and ComponentModel

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [October 12, 2021, 2:22pm UTC](https://forum.inductiveautomation.com/t/trigger-a-refreshbinding-props-data-from-inside-the-module/51687/12 "2021-10-12T14:22:12Z")

</div>

Hm, it should be safe to cast the `Component` you get inside your delegate to a `ComponentModel`. We could probably promote `refreshBinding` to the interface, but I don’t really see this architecture changing out from under you.

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [October 12, 2021, 2:31pm UTC](https://forum.inductiveautomation.com/t/trigger-a-refreshbinding-props-data-from-inside-the-module/51687/13 "2021-10-12T14:31:13Z")

</div>

Nice it works 😃

```auto
var property = PropertyKey.fromString("props.data");
var result = component.getSession().queue().runOrSubmit(() -> ((ComponentModel)component).refreshBinding(property));

```

---

<div class="post-metadata">

**Author:** ![conrad.fernandez](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/conrad.fernandez/32/38608_2.png) [@conrad.fernandez](https://forum.inductiveautomation.com/u/conrad.fernandez)\
**Post date:** [August 29, 2022, 7:30pm UTC](https://forum.inductiveautomation.com/t/trigger-a-refreshbinding-props-data-from-inside-the-module/51687/14 "2022-08-29T19:30:15Z")

</div>

I’m trying to do something similar. Currently, I’m able to trigger the refreshBinding of a table from a button on click event. I would like to trigger the refreshBinding for the table when the data changes on a tag value. How would you reference the table component for a tag change event?

Thanks

---

<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:** [August 29, 2022, 8:01pm UTC](https://forum.inductiveautomation.com/t/trigger-a-refreshbinding-props-data-from-inside-the-module/51687/15 "2022-08-29T20:01:08Z")

</div>

You don’t. Tags, themselves, have no access to anything in your user interfaces.

Instead, create a custom property on the table (or somewhere in the view) and bind the tag to that property. Then add an onChange action to that property that calls `refreshBinding`.

---

<div class="post-metadata">

**Author:** ![conrad.fernandez](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/conrad.fernandez/32/38608_2.png) [@conrad.fernandez](https://forum.inductiveautomation.com/u/conrad.fernandez)\
**Post date:** [August 30, 2022, 12:59am UTC](https://forum.inductiveautomation.com/t/trigger-a-refreshbinding-props-data-from-inside-the-module/51687/16 "2022-08-30T00:59:37Z")

</div>

Phil,

Thank you very much for your help!

Initially, I had tried binding the tag to a label, but the label does not have an on change event.

Your suggestion worked!
