Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

How can I un-select all selections before setting new selection via api

Qlik Sense extension :

I can set new selection like this ..

self.backendApi.selectValues(dim, [value], true);  // this simply add new selection to array

But before doing that I want to clear all selections ..

self.backendApi.clearSelections();   //  tried this but its not working ..

Some how I cant clear selections ?  I just want one selection to be active

1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

Found the solution thanks to Andre Ferreira

create dependency "qlik"

and then you can call following to clear all selections .

qlik.currApp().clearAll();

View solution in original post

10 Replies
mbm
Employee
Employee

Adeel,

Look into the ClearAll method in the Engine API

http://help.qlik.com/sense/en-us/developer/#../Subsystems/Qlik_Engine_API/Content/Classes/App class/AppClassClearAllMethod.htm

Anonymous
Not applicable
Author

Found the solution thanks to Andre Ferreira

create dependency "qlik"

and then you can call following to clear all selections .

qlik.currApp().clearAll();

ErikWetterberg

Hi Adeel,

The last parameter in the selectValues method is just for that. Check out:http://help.qlik.com/sense/en-us/developer/#../Subsystems/Workbench/Content/BuildingExtensions/API/b...

qToggleMode Boolean

If true, values in the field are selected in addition to any previously selected items.

If false, values in the field are selected while previously selected items are deselected.

so perhaps self.backendApi.selectValues(dim, [value], false); is what you need.

Anonymous
Not applicable
Author

Many thanks Erik .. it was very helpful ..  

Not applicable
Author

Just to add to this answer, setting the third parameter to true, as such:


backendApi.selectValues(dim, [value], true);

Will not only add any new selections made to previously selected items, but also will de-select/unselect any selections made that are already in the current selection. i.e. when set to true, if the user clicks on an item that is already selected then this item will be removed from the current selection.

rbecher
MVP
MVP

Hi Eric,

qToggleMode=false doesn't work in my case so the previous selection resists. Any advice?

Best,

Ralf

Astrato.io Head of R&D
rbecher
MVP
MVP

Ah, I was wrong. Using app.field.selectValues() which doesn't has this feature, or not?

Astrato.io Head of R&D
ErikWetterberg

Hi,

app.field.selectValues has a second parameter: toggle. Set that to false and your selections will override the selected values in the field.

Erik