Deep Kalra
Deep Kalra

Reputation: 1428

Tableau JS filter: Using javascript API, move filters from one dashboard to another

I am using Javascript API to embed tableau reports in my website. I want the default Tableau behaviour of it saving the filters of one dashboard in a workbook, while moving to another dashboard in the similar workbook.

For example:

If default date in a workbook is Jan-1 and I change it to Jan-2 in one of the dashboards, it should reflect in other dashboards in the same workbook. (In my embedded Tableau workbook!)

My code:

function initializeViz(url){
    var placeholderDiv = document.getElementById("tableauViz");
    var options = {
        width: placeholderDiv.offsetWidth,
        height: placeholderDiv.offsetHeight,
        hideTabs: true,
        hideToolbar: true,
        onFirstInteractive: function () {
            workbook = viz.getWorkbook();
            activeSheet = workbook.getActiveSheet();
        }
    };
    var x=url;
    if(viz!=null){
    viz.dispose();}
    viz = new tableauSoftware.Viz(placeholderDiv, url, options);
}

P.S.

This is closest thing I could find: Saving and restoring current view state of a Tableau graph through javascript API

I tried to find to find solution/documentation here: http://documents.tips/documents/javascript-api.html

Upvotes: 1

Views: 1368

Answers (1)

e h
e h

Reputation: 8893

I think you have two options here:

  1. If the user is changing a filter in the dashboard you can make the filter apply to all worksheets using the same data source (does not require the JS API and is very simple to do). enter image description here

  2. If you want to read the filters from the view and then apply them somewhere else you can use Worksheet.getFiltersAsync() which returns a collection of Filter classes.

Upvotes: 0

Related Questions