1 Reply Latest reply on Mar 2, 2015 11:33 AM by diego.medrano

    Getting the full list of options available in the filter dropdown via API

    Tahir Jadoon

      Hi, Is there a way to set filter by selecting the first option in the filter dropdown? Alternately, i was thinking about getting the dropdowns full list and then setting the filter per the first item. I have the following code that gives me the getAppliedValue(). How can i get the full list here, instead of the selected value? Please see the highlighted and bold code below. 

       

      function GetCustomerFilter(){

                  alert(1);

                  TableauViz.activeSheet = TableauViz.workbook.getActiveSheet();

                  var worksheets = TableauViz.activeSheet.getWorksheets();

                  for (var i = 0; i < worksheets.length; i++) {

                      var name = worksheets[i].getName();

                      var filters = worksheets[i].getFiltersAsync().then(reportCustomerFilter);

                  }

              }

              function reportCustomerFilter(filters){

                  for (var i = 0; i < filters.length; i++) {

                      var name = filters[i].getFieldName();

                      if(name == "Customer"){

                          alert("found customer");

                          var values = filters[i].getAppliedValues();

                          var myValues = "";

                          for (var j = 0; j < values.length; j++) {

                              if(myValues != ""){

                                  myValues += ", ";

                              }

                              myValues += values[j].value;

                          }

                          var customerData = "\n" + name + " = " + myValues;

                          alert(customerData);

                      }

                  }

              }

       

      Thanks.