3 Replies Latest reply: Sep 8, 2017 11:28 AM by André Sousa Silva RSS

    Selecting a value in a widget

    Richard Bartley

      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,



        • Re: Selecting a value in a widget
          Sean Anderson





          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[i].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[y].qName : t += "\n" + c[y].qName;



            //All selection to console

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


            • Re: Selecting a value in a widget
              Richard Bartley

              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.



                • Re: Selecting a value in a widget
                  André Sousa Silva

                  Hi Richard,


                  I have same problem:





                  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: