Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Announcements
Make your voice heard! Participate in the 2020 Wisdom of Crowds® Survey. BEGIN SURVEY
Highlighted
Not applicable

Button color change when selecting/deselecting (toggle selection)

Hi All,

I want to change the color of a button depending on whether the button is activated or deactivated.

I tried the following:

- Setting up a variable Button

- Set variable on Button Click (Variable = vbutton, Value = 1)

Then I set up a calculated button color:

If(vButton = 1, RGB(20, 255, 8), RGB(247, 159, 8,))

The result is, that the button color changes when selecting the button. So far so good. I want the button color to change back to the original color though when I am pressing the button again (which means "deselection" in my application, because I defined a toggle selection on button click as well).

How can I do this?

Thanks very much in advance

Rgds Stephan

1 Solution

Accepted Solutions
Highlighted
MVP
MVP

Re: Button color change when selecting/deselecting (toggle selection)

Hi

Change the value in the action to the expression:

=If(vButton = 0, 1, 0)

This will toggle the button between 1 and 0. Your colour expression should work fine.

HTH

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein

View solution in original post

6 Replies
Highlighted
MVP
MVP

Re: Button color change when selecting/deselecting (toggle selection)

like this?

Update : Change color according to your need.

Highlighted
MVP
MVP

Re: Button color change when selecting/deselecting (toggle selection)

Hi

Change the value in the action to the expression:

=If(vButton = 0, 1, 0)

This will toggle the button between 1 and 0. Your colour expression should work fine.

HTH

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein

View solution in original post

Highlighted
nizamsha
Valued Contributor II

Re: Button color change when selecting/deselecting (toggle selection)

PFA

Highlighted
MVP
MVP

Re: Button color change when selecting/deselecting (toggle selection)

set variable should be

=if(vButton=1,0,1) or as Jonathan suggest

and calculated color should be

If( vButton = 1, RGB(20, 255, 8), RGB(247, 159, 8))

instead of (removelastcomma)

If(vButton = 1, RGB(20, 255, 8), RGB(247, 159, 8,))

you can use an input box to check your variable

1.png

Highlighted
Not applicable

Re: Button color change when selecting/deselecting (toggle selection)

Thanks all, this really worked well - I was not aware of the 0,1,0 logic.

Bloody beginner me

Highlighted
Not applicable

Re: Button color change when selecting/deselecting (toggle selection)

Follow these easy steps

1. Create a variable vChange and assign value to 1

2. Select a button object and give proper name.

     In the button properties

      -> In general tab Color property-> Add calculated color expression : =If(vChange=1,Green(),Red())

     In the Actions tab-> Add actions as Setvariable

                              -> Variable : vChange (without "=")

                              -> Value : =If(vChange=1,0,1)

Now click and see