Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
It seems that where there is a conflict of selections then all selections are removed.
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
Below extension provides a dropdown option, where you can select only one.
Thanks, but I want to avoid using an extension.
It seems that where there is a conflict of selections then all selections are removed.
@rbartley , can you please help on this
https://community.qlik.com/t5/New-to-Qlik-Sense/How-To-pass-values-in-field-based-on-condition-in-se...