Skip to main content
1-Visitor
May 6, 2016
Question

Is there a way to change the visibility of widgets based on Button Click event?

  • May 6, 2016
  • 1 reply
  • 4945 views

I would like to show and hide widgets based on which button is clicked. Is there a way currently to bind the click of a button to the "Visible" attribute of another widget (such as a map for instance) ?

1 reply

5-Regular Member
May 6, 2016

Fatima, 'Visible' is a boolean property, and buttons work based on 'clicked' events. What you would need to do is write a service which outputs true or false as results based on its execution. You would need to bind this service output to the visible property, and bind the button click to this service. Each time you click the button, this service will get executed, sending true or false (show or hide) to the visible property.

1-Visitor
May 9, 2016

Thank you Anjan for your reply!

However, I am also trying to toggle the visibility based on multiple buttons click events. For instance button1 clicked --> show element A and hide Element B and Button 2 clicked --> hide Element A and show Element B.

The visibility attribute only takes one biding and I am not able to use the visibility attribute as an input to service.

Is there a way to toggle the visibility similar to an (ng-show or ng-if) in AngularJS.

1-Visitor
May 9, 2016

Maybe you can have a Service which outputs an InfoTable with a DataShape of two booleans (one for each element). The input is the current state of the two elements. Each button which should toggle the visibility can invoke the same Service.