Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
rbartley
Specialist II
Specialist II

Selecting a value in a widget

Hello all,

I have developed a widget that takes a dimension and shows all the associated year values in a lui-select list. I have also linked this up to a function that filters the year field.  Elsewhere I apply a default filter using app.field.selectMatch Which is triggered on load. However, the widget does not show the default value as being selected.  Can anyone tell me how I can programaticaly show the selected value?

I tried using $('#widget').val('defaultyear'); but this didnt work.

Thanks in advance,

RIchard

3 Replies
Anonymous
Not applicable

getList("CurrentSelection",callback())

ex:

qsApp.getList("CurrentSelections", function(r){

  var t = "";

  var f = r.qSelectionObject.qSelections;

  var f_a = f.length;

  for (var i = 0; i < f_a; i++) {

        var c = f.qSelectedFieldSelectionInfo;

        var c_a = c.length;

        for (var y = 0; y < c_a; y++) {

            //Build output of selections- could be returned as object instead

            y == 0 ? t += c.qName : t += "\n" + c.qName;

        }

  }

  //All selection to console

  if(t !== "") { console.log(t) }

});

rbartley
Specialist II
Specialist II
Author

Hello Sean,

Thanks for responding.  I have looked at your example, but it seems as though it reads the selected value but does not mark the value as selected within the control so that it appears at the top of the list as it would if I manually selected a value from the list.  It is this latter step that I am asking about.

Richard

Anonymous
Not applicable

Hi Richard,

I have same problem:

app.field("YYYYMM.autoCalendar.YearMonth").selectMatch(["2011-May"],true);

app.field("YYYYMM.autoCalendar.YearMonth").selectMatch(["2011-05"],true);

app.field("YYYYMM.autoCalendar.YearMonth").selectValues(["2011-May"], true, true); 

app.field("YYYYMM.autoCalendar.YearMonth").selectValues(["2011-01"],true, true);

app.field("=Dual(Year([YYYYMM])&'-'&Month([YYYYMM]),MonthStart([YYYYMM]))").selectValues(["2011-May"], true, true); 

app.field("=Dual(Year([YYYYMM])&'-'&Month([YYYYMM]),MonthStart([YYYYMM]))").selectValues(["2011-01"],true, true);

Manually work:

Print3.png