Property/parameter binding between views

Hello,

New guy here just trying his best.

I have struggled with binding properties between views. I have managed to do it, but there must be a more efficient way of doing this.

I want to change a tag path in a subview by changing a property value in a mainview. This requires that the tag path in the subview is referencing a property from the main view.

First I made a bidirectional memory tag and wrote the value property from a dropdown in the main view to this memory tag. In the subview, I bind this memory tag to a different dropdown (that i visually hide) to convert the memory tag value to a property value within the subview. see the image below.

Pretty dumb but it works.

Can it be done simpler?

I don't think you need the dropdown in the subview. You should be able to bind it to a param or custom prop on the view itself:

https://docs.inductiveautomation.com/display/DOC81/Property+Bindings+in+Perspective#PropertyBindingsinPerspective-PassaPropertyintoanEmbeddedViewUsingaViewParameter

  1. Locate the View you're using in the Embedded View, and select the named View node (not the root node).
  2. In the Perspective Property Editor, underneath CUSTOM, you'll see PARAMS.
  3. Add a new View parameter of type value.
  4. Change the key of this new param to be path (it could be anything, but since you'll be using it to represent a passed-in tag path, "path" makes sense.
  5. If desired, you can set a default value for this parameter. I usually just set it to an empty string at this point.
  6. You also have the option of modifying the data direction (in, out, in/out), but you just need the default "input" mode for this use-case.
  7. Save your changes.
  8. In the "main" view, locate your Embedded View.
  9. Within the props of the Embedded View, locate params.
  10. Click "Add Object Member" then in the resulting popover, hover over "Parameters" and select "path".
  11. Now, just bind the value of EmbeddedView.props.params.path to whatever path you desire.

I realize this looks like a lot of steps, but it's easier than this post makes it look - especially after you've done it previously. Also, this process is a bit more intuitive if you do it while you're building the View to be instanced/embedded.

4 Likes

Now, that is the proper way to do it!

Thank you

1 Like