Updating Table through actions in an Embedded View

I am new to using views inside of tables using Perspective. I have gotten as far as customizing those embedded views, passing data down into them from the table, manipulating that data, and updating data within my SQL database. That all works great and was pretty easy to do with a little bit of digging. However, I am having an issue with updating the table in the parent view once I carry out my update script in the embedded view.

Is there any functionality with scripting in Perspective that allows a table to refresh it's data when an action is carried out on an embedded view?

Not directly.

What you'll want to do is after your update code completes, broadcast a message with system.perspective.sendMessage() (make sure you're specifying a page scope). Your Table should have a configured listener (listening at the page scope). On receipt of the update message, the Table's code should invoke self.refreshBinding("props.data").

1 Like

That did the trick!

I also found out that since I am using system.db.runNamedQuery as an update method, I had to use system.utils.invokeAsynchronous so I could carry out actions after the update was successfully processed.

Not on familiar territory here, as every script I write is usually blocking, but it the refresh is done async, wouldn't there be a chance that you'll miss refresh events because of certain race conditions (i.e. you send the refresh message before the update is finished)?

I know you can specify a callback - I wonder if that's how it gets used. Again, complete async noob trying to understanding how it works so that I can recognize potential use cases in the future.

1 Like