1 Reply Latest reply on Nov 9, 2015 10:15 PM by Tamas Foldi

    Simple showOnly / Filter Dashboard with API Hiccup

    Stephen Hellyar

      I know this is pretty basic.


      I want to filter a dashboard (not an individual sheet).  But, I can't get it to work.  I am using the following function.  I have had success with this approach in the past, but it no longer seems to be working.  Everything else (e.g., chaining parameter settings, etc.) else seems to be working.  And I don't see any errors popping up in the browser consoles.   The filters are all set to apply to all worksheets in the source desktop dashboard.

       

      I am using  onClick="showOnly("Filter", "Value").  I also checked my keyboard settings were set to straight single/double quotes, etc.

       

      Here's how I initialize mainViz and the function I am trying to use to showOnly.

       

      Thanks.

       

      window.onload=function() {

          var mainVizDiv = $("#mainViz");

          var mainWorkbookUrl = "https://10az.online.tableau.com/#/site/MyURL";

          var mainVizOptions = {

              hideTabs: true,

              hideToolbar: true,

              //toolbarPositon: top  (or "bottom")

              width: "1200px",

              height: "675px",

              onFirstInteractive: function () {

                  mainWorkbook = mainViz.getWorkbook();

              }

          };

          mainViz = new tableau.Viz(mainVizDiv[0], mainWorkbookUrl, mainVizOptions);

      }

       

      function showOnly(filterName, values) {

        sheet = viz.getWorkbook().getActiveSheet();

        if(sheet.getSheetType() === 'worksheet') {

        sheet.applyFilterAsync(filterName, values, 'REPLACE');

        } else {

        worksheetArray = sheet.getWorksheets();

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

        worksheetArray[i].applyFilterAsync(filterName, values, 'REPLACE');

        }

        }

      }

       

      ...