Sense Mashup API Selecting on one field removes selection on another
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.
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.
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.