4 Replies Latest reply on Feb 16, 2016 12:38 PM by Robert Yu

    Getting all the filters applied to the sheet via javascript api

    Tahir Jadoon

      Is there a way to get all the filters applied to the sheet/dashboard via javascript api? The viz displays on our site, the filters are specified on the viz. I need to know the filters that the user on our site may have applied to the sheet.

       

      Here is my current call:

       

      <script type="text/javascript">

       

              //call and setup is at the end of TableauViz name value function

              var TableauViz = {

                  viz: '', //global object

                  workbook: ''//global object

                  activeSheet: '', //global object

                  vizUrl: '',

                  tableauVizContainer: 'tableauVizDiv',

                  initilize: function () {

                      if (TableauViz.vizUrl != '') {

                          TableauViz._getVizOnLoad();

                      }

                  },

                  _getVizOnLoad: function () {

                      //this will hold our viz

                      var vizDivObject = document.getElementById(TableauViz.tableauVizContainer);

                      var viz, workbook, activeSheet;

                      var options = {

                          width: vizDivObject.offsetWidth,

                          height: "700px", //vizDivObject.offsetHeight,

                          hideTabs: false,

                          hideToolbar: true,

                          onFirstInteractive: function () {

                              workbook = viz.getWorkbook();

                              activeSheet = workbook.getActiveSheet();

       

                              if (activeSheet.getSheetType() === 'dashboard') { //worksheet or dashboard

                                  //this is dashboard, resize auto

                                  activeSheet.changeSizeAsync({

                                      behavior: tableauSoftware.SheetSizeBehavior.AUTOMATIC

                                  });

                              }

       

                              //populate global objects to be used later

                              TableauViz.viz = viz;

                              TableauViz.workbook = workbook;

                              TableauViz.activeSheet = activeSheet;

                          }

                      };

                      viz = new tableauSoftware.Viz(vizDivObject, TableauViz.vizUrl, options);

                  }

              };

       

              //setup and call

              TableauViz.vizUrl = '@Model.VizUrl'; //Assign viz url

              $(document).ready(function () {

                  TableauViz.initilize();

              });

       

          </script>