简体   繁体   中英

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);
}

PS

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

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). 在此处输入图片说明

  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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM