Qlik Community

Qlik Sense Integration, Extensions, & APIs

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

rbartley
Valued Contributor

Sense Mashup API Selecting on one field removes selection on another

Hello everyone,

I am experiencing some rather odd behaviour in my mashup.  I have the following code on my page, which is intended to change the selected year when the value is changed in a drop-down list ( I am not using the Qlik filter pane because the user should only be able to select one value, something that I don't think that the standard Qlik field filters are capable of).

Anyway, when I load the page, I filter on two fields (pig category and year) and this works fine, but when I select a new value in the drop-down list, it filters the year correctly, but removes the filter on Pig Category (Price).  While testing, I added lines 8 to 13 below and this re-applies the filter on Pig Category (Price), but not on the first change. 

$('#lstYearPrice').change(function(event,obj){

  var intSelectedYear;

  intSelectedYear = Number(event.target.value);

  app.field("[Year (Price)]").selectValues([intSelectedYear],false,true);

  if(strPigCategory=='Piglet')

  {

  app.field("[Pig Category (Price)]").selectValues(['Piglet'],false,true);

  }

});

I have de-bugged the code in IE's developer console, but I cannot see anywhere where a call to remove the filter is made.  I have also tried all the combinations of false and true associated with the selectValues method, but nothing seems to work.

Anyone have any ideas?

Thanks in advance

Richard

Tags (1)
1 Solution

Accepted Solutions
rbartley
Valued Contributor

Re: Sense Mashup API Selecting on one field removes selection on another

It seems that where there is a conflict of selections then all selections are removed.

4 Replies
rbartley
Valued Contributor

Re: Sense Mashup API Selecting on one field removes selection on another

I believe I have located the issue.  it appears to be due to the fact that a 'latest year' filter is applied as part of the default filters I applied when the page is loaded. When the year is selected from the list, the chart is changed to reflect this and so this appears to be working, but the category is removed for some reason.  However, when I cleared the 'latest year' selection, the category selection stayed as it should.  I also found that there was a synchronicity issue, which I had to use a deferred object to resolve.  First of all I cleared the latest year selection, then when the deferred object had been resolved, I applied the selection of the year from the drop-down list.  All appears to be working correctly now.


I'm still not sure exactly what caused the category selection to be removed, so if anyone has any ideas about this, I would be interested to hear.


Richard

s29124141
Contributor II

Re: Sense Mashup API Selecting on one field removes selection on another

Below extension provides a dropdown option, where you can select only one.

http://branch.qlik.com/#!/project/57b75fd3b3122e2cd1e72fdf

rbartley
Valued Contributor

Re: Sense Mashup API Selecting on one field removes selection on another

Thanks, but I want to avoid using an extension. 

rbartley
Valued Contributor

Re: Sense Mashup API Selecting on one field removes selection on another

It seems that where there is a conflict of selections then all selections are removed.

Community Browser