Hide components with condition

HI, so i have this idea that i add lights (for example) and i have a button for that light, and then a OPC TAG connected to that button. Now, i want this button to disappear in case the OPC Tag is not working (bad connection) and if it is connected then reapers.
Does anyone knows how it can be done?

Perspective

Use a tag binding on the props.position.display property with an expression transform to see if the tag is good.

Vision

Use an expression binding on Common.Visible property of the button with an expression like:

isGood([yourProvide]path/to/tag)

1 Like

The advice from IA on Using tag data quality to set tag value - #5 by PGriffith is to use the isGood() function rather than checking a range of values. It's also much shorter and more clear what the code is doing.

Welcome to the forum!

You don't need two steps; you can just put the tag property directly in the expression, the same as Vision. It's likely faster to do so.

2 Likes

An extra question, if i may: I sometimes bind the visible tag but sometime, when i have more buttons that hides/shows the same component that is already bind, i use the script "self.getSibling"Component".meta.visible = 1 or 0. And it works fine.
But i am trying to figure it out how to make this to another view. Like, a button that if it pressed, then when i nav to another view and certain component will be hidden or shown.
Do you happen to now how the function to call other components and props in another views works?

If the other view is open, then a message handler can be used.

If you are opening the view with the button, then you would need to send a parameter to the view to hide/show the components.

The view is not open.
Context: House model, i have various nav buttons on "Home Page" that navigate to each select room (ex: kitchen, garage, Bedrooms, etc). Now, when i nav to "Bedrooms Page" i have 3 other nav buttons referring to each bedroom (ex: bedroom 1, bedroom 2 and bedroom 3).
What i want to do, is in the home page, create a slide with 1, 2, 3 values, and i create a script with an "if" and accordingly to witch number the slider is and it correspond to the number of bedrooms there are available. So if the slider is on 1, only the button "Bedroom 1" will show up when i navigate to "Bedrooms Page", and if the slider is on 2, then the buttons "Bedroom 1" and "Bedroom 2" will show up.
Problem: I dont know how to change other views properties/metas, only getSibling/parent/getChild that only work on the same view.

You would pass in the "Number of Bedrooms" as a parameter when you navigate to the view.

You can do that with system.perspective.navigate()

https://docs.inductiveautomation.com/display/DOC81/system.perspective.navigate

You cannot. Views do not have access to components of other views. You must use bidirectional view parameters or bidirectional bindings to session properties or messaging.

1 Like