Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

ank
New Contributor II

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
ank
New Contributor II

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

Found the solution thanks to Andre Ferreira

create dependency "qlik"

and then you can call following to clear all selections .

qlik.currApp().clearAll();

10 Replies
mbm
New Contributor III

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

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

mbm
New Contributor III

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

ank
New Contributor II

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

Found the solution thanks to Andre Ferreira

create dependency "qlik"

and then you can call following to clear all selections .

qlik.currApp().clearAll();

erik_wetterberg
Valued Contributor III

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

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.

Erik Wetterberg
https://extendingqlik.upper88.com/
ank
New Contributor II

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

Many thanks Erik .. it was very helpful ..  

Not applicable

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

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.

MVP
MVP

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

Hi Eric,

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

Best,

Ralf

MVP
MVP

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

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

erik_wetterberg
Valued Contributor III

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

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

Erik Wetterberg
https://extendingqlik.upper88.com/
Community Browser