Binding property between different views

Hi everyone! I’m trying to bind a property between different views.
On viewA, I have a dropdown with two options: siteA and siteB, and a button. When a user clicks the button, it will popup viewB. I want to bind the dropdown.props.value property of site A to a label’s value on ViewB for making a decision later. It seems like Ignition does not support binding property between different views.
How I can do to deal with this problem? I find Message Handler may be the answer, but I do not know how to implement it.

Thank you so much for your time!

There are multiple ways and which you choose depends on how you need to use the value and who needs to know about the value.

  1. a memory tag
    Who needs to know: all clients + the gateway, value is changed for all
    Method: bidirectionally bind your component properties to the memory tag.

  2. a custom session prop
    Who: only the current client, all clients will have their own version
    Method: create a custom session prop and as in 1, bidirectionally bind this to your component properties.

  3. a message handler
    Who: a single client or multiple clients
    Method: create a message handler on your dropdown component that listens on the page scope and expects a value passed in via the payload which writes this value to its selected value prop. On the popup, send a message via system.perspective.message to the message handler with the new value in the payload. (very brief description)
    This is the least favourable method for what you’re trying to do

1 Like

Yeah, it’s quite an informative answer. Thanks for your help!
I prefer the second and third solutions to the first solution. Because I do not want all clients and the gateway to know when a specific client triggers an event.

This is how you’ll want to configure the listeners. This is an important part of the send/receive process.

It’s worth noting that this process might NOT work for your scenario, as even if you send the message to the Popup, the Popup MUST be open before you send the message or it will not be received. It seems like what you should be doing is passing the site information as a parameter of the Popup view. Alternatively, you could use the custom session property pattern.

1 Like

Thanks for your help!
I have tried to use the custom session property. It worked well. It seems like we are setting a global variable for all views in a session.
I have not tried Message Handler yet. Could you describe in more detail what I need to pass a parameter to the Popup view?

For whatever View you will be using in the Popup, open that view in the designer, and with the View node selected in the Project Browser you should find that you have access to a category of properties called PARAMS. You should add a property or properties of the shape you require here. Make a mental note of the property names, as you’ll need to reference them with case-sensitive matches later on.

For the rest of this example, you’ll see that I’m using a param with a key of “some_param_here” which belongs to a View located at the root of the Views directory and is named “Repl”.

Now, if you’re using a Popup Action:

If you’re using a Script Action:

system.perspective.openPopup(id="MyPoPuP", view="Repl", params={"some_param_here": "Value2"})
1 Like

Yeah, it’s very helpful. Thanks for your help!

1 Like