Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
QlikKing99
Contributor
Contributor

Vizlib Buttons Toggle Field Selection

Hey all,

Recently I have begun using the Vizlib add-on library and so far, I'm loving the customizability. The only issue I am having is that Vizlib actions are simply - different - than the built-in button actions.

Goal: I want to be able to replicate Qlik's stock built-in "toggle field selection", but on a more customizable Vizlib button. Thus, if the user has an existing selection A, B and selects C, the user should obtain A, B, C. Upon selecting C again, the user should obtain A, B. This should also work if the selection already exists, say, from a filter pane.

What I've tried:

Attempt 1

Add Action -> Selection in Field -> 'Field_A' -> 'A1'

Result: Overwrites any existing selection to 'A1'. Also does not turn off value.

Attempt 2

Add Action -> Selection in Field -> 'Field_A' (populated with code below)

if(isNull(SubstringCount(GetFieldSelections([Field_A]), 'A1')), 'A1',

if(SubstringCount(GetFieldSelections[Field_A]), 'A1') = 0, '(' & GetFieldSelections([Field_A]) & '|A1)',

Replace(GetFieldSelections([Field_A]), '|A1', '')))...similar replaces for all cases

Result: This gives some of the functionality but with limitations. Namely, if the initial selection is made on a filter pane or similar, Qlik returns A, B. But using this logic, Qlik returns (A, B | C) which results in just C  (or in an error).

Attempt 3

Similar to above, but I try

'(' & GetFieldSelections([Field_A]) & ',A1)',

Errors. Deselects everything (probably because of a null selection).

 

I'm still pretty new to Vizlib, so if anyone has any feedback or a secret way to do this by turning on a hidden option, please let me know, thanks. 🙂

Labels (2)
0 Replies