Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

hide and show object on click of command button

How can i add a functionality that my object will appear and hide on click of same command button like ON/OFF.

Thanks

Manish

1 Solution

Accepted Solutions
johnca
Specialist
Specialist

Hi Manish,

You can create a variable, say vShowObject. Then create a button (or text object) and assign an action that says Set variable =if(vShowObject =1,0,1). Then use the Show Condition on the Layout tab of your object you want to show or hide and set it to vShowObject = 1. Play around with it. You can use the same logic to change the 'On' and 'Off' displayed.

--john

View solution in original post

10 Replies
johnca
Specialist
Specialist

Hi Manish,

You can create a variable, say vShowObject. Then create a button (or text object) and assign an action that says Set variable =if(vShowObject =1,0,1). Then use the Show Condition on the Layout tab of your object you want to show or hide and set it to vShowObject = 1. Play around with it. You can use the same logic to change the 'On' and 'Off' displayed.

--john

maxgro
MVP
MVP

see attachment

Anonymous
Not applicable
Author

Hi John,

It will either ON or OFF to move from ON to OFF i need to change the value of variable manually.

What i want is on first click on command button my object will appear on second click it show disappear and again on click it appears like that.

Anonymous
Not applicable
Author

attachment missing

maxgro
MVP
MVP

I can see my attachment

1.png

Anonymous
Not applicable
Author

it seems to due to some network issue it is not delivered properly,could you please attach it again.

maxgro
MVP
MVP

ok

johnca
Specialist
Specialist

Hi Manish, what I attached does exactly as you wish; 1 click shows the object and the text on the button says "Hide". The next click hides the object and the text on the button says "Show". Each click of the button repeats the process. I can't think of a more simple and elegant solution than this.

Do exactly as I outlined.

1. Create variable vShowObject (or whatever name you desire)

2. Create button.

3. Set Button text: =if(vShowObject=1,'Hide','Show'). This alters the button text between Show and Hide.

4. Set button action: Set Variable, and set Variable field to vShowObject, then Value field to =If(vShowObject=1,0,1). This sets the variable from 0 to 1, and from 1 to 0, depending on its current state.

5. Create the object you want to show and hide.

6. Go to Layout tab of the desired object and Show Conditional and set it to vShowObject=1. This will then show the object when vShowObject equals 1. It hides it when it is not equal to 1.

Regards,

John

johnca
Specialist
Specialist

Hi Manish,

Please close this thread by selecting an answer as Correct or Helpful. Thanks!