I have created an event inside of a View that when a button is clicked it fires a script to input data from a form into a database table. However I need to bind and display this data to a table inside another view (popup view). I know that I have to set my input and output params, which I have done but my question is am I able to do this inside of the event in the main view? Can I use object traversal to reference the table in the other view? See attached screenshots.
You cannot use object traversal to access components in other views. Full stop.
Post code, not pictures of code, so we can copy and edit it in our answers. See Wiki - how to post code on this forum.
Do you have another suggestion or example of how I could do this? Parameters should allow me to pass data in and out of views. I cannot access the other view from the property browser inside the script. So, this is why I asked about traversal.
Why not bind your popup table to the database where you submitted your form data instead of populating the table with a passed parameter?
Totally agree with this - the best paradigm that shows up all over the place in Perspective programming (esp when submitting forms) is to bind your table to a query that looks at the table you're submitting a record into (so in this example, ShipmentDetails
).
Then, submit your form with an event like you have in your screenshots. The last part of this is to send a refresh message to your table, which will query the database and get the most up to date data - that way, you don't deal with passing large datasets between views.
For example, on line 39 in your script, you can add
# use a good message handler name, obviously
system.perspective.sendMessage("RM_UpdateShipmentDetails")
# or you can use
system.perspective.sendMessage("refresh")
# if you want to refresh many components on the screen with one call
and then on your popup view, you can receive that message, either on the root container or the Table component itself and do something like
# this assumes the message handler is defined on the Table itself
self.refreshBinding("props.data")
[For this to work, you need a binding on props.data
tied to your database table.]