Auto-refresh table in perspective

I have a table in perspective that is populated by a script that goes and gets data from some tags and other places and calculates/formats things to display to the user. The table loads when the view is loaded in perspective but I want it to refresh ideally when one of the underlying tags changes. What’s the best way to do this? Even a simple loop updating the table every couple of seconds whether the tags have changed or not would be fine (though not ideal), but I can’t figure out how to do that.

PS - I tried calling self.refreshBinding(self.getSibling(“TableNameHere”).props.data) from a couple of different places but this yields the error “TypeError: refreshBinding(): 1st arg can’t be coerced to String” in the wrapper log.

That’s not the appropriate syntax to call refreshBinding - it’s a component method, so you would go to the sibling, then call `refreshBinding(“props.data”):

self.getSibling("TableNameHere").refreshBinding("props.data")

2 Likes

If the table is global (no user specific items), another option might be to put the script in a Gateway Event Script (Timer or Tag Change) and write it to a dataset tag. Then point the perspective table to the tag.

I am not clear on where this refreshBinding would be triggered. I can place this on a button and it refreshes but I need it to poll like a Tag, Query, or tag History. Example: every 30 seconds. Is there a session event that I can setup a timer?

Okay, i figured it out. The runScript('myscript', 30) has a polling parameter.

Awesome, i fixed that.