Qlik Community

Qlik Sense Integration, Extensions, & APIs

Discussion board where members can learn more about Integration, Extensions and API’s for Qlik Sense.

bryan_sng
New Contributor III

Qlik Mashup API selectValues

Hello guys,

Recently I have this issue about deselection using selectValues when selection is invalid.

Assuming my extension has 2 dimensions (Zip Code, Building Name)

Let's assume some data too:

Zip CodeBuilding Name
11111AAA
11111BBB
11111CCC
22222DDD
22222EEE

Suppose the user current selection is:

Zip Code: 11111

Building Name: AAA, BBB, CCC

What I does is to programmatically select the rest of the data:

app.field('Zip Code').selectValues([22222], true, true);

app.field('Building Name').selectValues(['DDD', 'EEE'], true, true);


Then programmatically deselect the rest of the data:


app.field('Zip Code').selectValues([22222], true, true);

app.field('Building Name').selectValues(['DDD', 'EEE'], true, true);


The result would be Building Name selection unable to deselect because the deselection of Zip Code has render the current 'DDD' and 'EEE' to be gray out in the selection bar. Repeatedly calling

app.field('Building Name').selectValues(['DDD', 'EEE'], true, true);


has no effect unless I select back Zip Code 22222 to "enable" the Building Name "DDD", "EEE".


Do you guys have any workaround or even better, the correct way to deselect even when the selection is gray out?


1 Solution

Accepted Solutions
erik_wetterberg
Honored Contributor

Re: Qlik Mashup API selectValues

I think you need an unique ID for each selectable marker to make this work. Say for example that the user select

  1. zip 1111, building AAA
  2. zip 1111, building BBB
  3. then deselects the first marker, should you deselect zip 1111 or not??

Or another example, the user selects

  1. zip 1111, building AAA
  2. zip 2222, building BBB

If the data now contains also 1111, BBB and/or 2222, AAA they will also be selected.

If you instead used a unique id (possibly concatenation of zip + building) you can use just that field for selection and the associative logic will fix the rest.

I hope I have not misunderstood everything...

Erik

Erik Wetterberg
https://extendingqlik.upper88.com/
6 Replies
erik_wetterberg
Honored Contributor

Re: Qlik Mashup API selectValues

Why don't you use app.field('Building Name').clear() ?? Or possibly use app.field('Building Name').selectExcluded() ??


Erik

Erik Wetterberg
https://extendingqlik.upper88.com/
bryan_sng
New Contributor III

Re: Qlik Mashup API selectValues

Yup, that's exactly what I have done finally but it does require several code changes to use the clear method.

Previously:

1) Get the current selection from custom extension object

2) Append current selection to qlik selection bar

Currently:

1) Get the current selection from qlik selection bar

2) Get the current selection from custom extenstion object

3) Clear current selection from qlik selection bar

4) Combine #1 and #2 selections together

5) Append #4 selections to qlik selection bar

erik_wetterberg
Honored Contributor

Re: Qlik Mashup API selectValues

I'm afraid I don't understand what you are trying to do.

Your first step is selecting the rest of the data (selectAlternative ??). Does that work as expected?

Then you want to go back to the initial selection? Is that what does not work??

Erik

Erik Wetterberg
https://extendingqlik.upper88.com/
bryan_sng
New Contributor III

Re: Qlik Mashup API selectValues

Hmm basically I'm doing a map extension.

User is able to select plotted markers on the map.

When selecting a plotted markers, based on the marker attributes, I will make a selection via selectValues to qlik side.

So for example user now click on a train station in USA, user will see Zip Code 111 and Product ID AAA at qlik selection bar.

If user now decided to deselect the marker, system should remove the Zip Code 111 and Product ID AAA at qlik selection bar which is perfectly ok now since there is no other selection.

However if user make another selection 1st before deselecting, say for example another bus station in Canada, user will see Zip Code 111, 999 and Product ID AAA, FFF at qlik selection bar.

If user now decided to deselect the marker at USA, system should remove the Zip Code 111 and Product ID AAA at qlik selection bar so that only Zip Code 999 and Product ID FFF remains.


However this will not work as after executing the following, the value for Product ID AAA will be gray out:

  app.field("Postal Code").selectValues("111", false, true);

Subsequently executing the following to deselect Product ID AAA will not cause any effect in the selection bar.

  app.field("Product ID").selectValues("AAA", false, true);

erik_wetterberg
Honored Contributor

Re: Qlik Mashup API selectValues

I think you need an unique ID for each selectable marker to make this work. Say for example that the user select

  1. zip 1111, building AAA
  2. zip 1111, building BBB
  3. then deselects the first marker, should you deselect zip 1111 or not??

Or another example, the user selects

  1. zip 1111, building AAA
  2. zip 2222, building BBB

If the data now contains also 1111, BBB and/or 2222, AAA they will also be selected.

If you instead used a unique id (possibly concatenation of zip + building) you can use just that field for selection and the associative logic will fix the rest.

I hope I have not misunderstood everything...

Erik

Erik Wetterberg
https://extendingqlik.upper88.com/
bryan_sng
New Contributor III

Re: Qlik Mashup API selectValues

Hmm for your 1st scenario,

  1. zip 1111, building AAA
  2. zip 1111, building BBB
  3. then deselects the first marker, should you deselect zip 1111 or not??

No, zip 1111 and building BBB will be selected finally.

For your 2nd scenario,

  1. zip 1111, building AAA
  2. zip 2222, building BBB

If the data now contains also 1111, BBB and/or 2222, AAA they will also be selected.

It's not possible because if the qlik selection bar already contains 1111, BBB and/or 2222, then at the map side, those markers would already be selected so subsequent selection of them will only cause deselection instead.

Finally yes I implemented with your unique id strategy and got over the hurdle, thanks a lot Erik!

Community Browser