Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
rbartley
Specialist II
Specialist II

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

1 Solution

Accepted Solutions
rbartley
Specialist II
Specialist II
Author

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

View solution in original post

5 Replies
rbartley
Specialist II
Specialist II
Author

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
Partner - Creator II
Partner - Creator II

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

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

rbartley
Specialist II
Specialist II
Author

Thanks, but I want to avoid using an extension. 

rbartley
Specialist II
Specialist II
Author

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