我正在尝试使用JavaScript API配置默认过滤器选择状态。这是我用于此示例的代码:
$(function() {
var placeholderDiv = document.getElementById("tableauViz");
var url = "https://sometableausite/t/Tableau_Dev/views/MyPath/HomeDashboard?:embed=y&:showShareOptions=true&:display_count=no&:showVizHome=no";
var options = {
hideTabs: false,
width: "100%",
height: "1552px",
onFirstInteractive: function() {
var worksheet;
var filtersVal='';
var onSuccess = function (filters) {
console.log("This worksheet has " + filters.length + " filter(s) associated with it.");
$.each(filters, function (filter, i) {
// use .value property of each DataValue object
filtersVal += i.getFieldName() + ", ";
console.log(filtersVal);
});
};
var onError = function (err) {
console.log(err);
};
viz.getWorkbook().activateSheetAsync("Performance").then(function(sheet) {
worksheet = sheet;
worksheet.getWorksheets()[0].getFiltersAsync().then(onSuccess, onError);
});
}
};
var viz = new tableau.Viz(placeholderDiv, url, options);
});
这只是试图在这一点上获取可用的过滤器选项,但是我会遇到500个服务器错误并在调用Worksheet.getWorkSheets()[0] .getFiltersAsync()时遇到OnError调用。
这是返回的错误:
发布到https://woryableAusite/vizql/t/t/tableau_dev/w/mypath/v/homedashboard/sessions/e49db48c495e4a858821b951b95aefb95aefb20-0aefb20-0:2/commands/commands/commands/commands/tabsrv/get-filter-filter-filter-info
给出500服务器错误。
tableauexception:内部错误
2016-06-22 19: 27: 53.350( v2rmuqrmaa0aaeegqy60aaaalp,0,2)
我该怎么做才能获取可用的过滤器列表?
我在试图查询可用过滤器选项时无法克服问题中的错误。相反,我通过简单地将过滤器添加到所用的URL中找到了解决方法。
$(function() {
var placeholderDiv = document.getElementById("tableauViz");
var url = "https://sometableausite/t/Tableau_Dev/views/MyPath/HomeDashboard?Business Unit Name=Accounting";
var options = {
hideTabs: true,
width: "100%",
height: "1552px"
};
var viz = new tableau.Viz(placeholderDiv, url, options);
});