为什么powerbi.load方法不再起作用?

时间:2019-02-08 18:36:20

标签: powerbi powerbi-embedded powerbi-js-api

我正在通过powerbi js Embedded(ajax)将powerbi报表嵌入到我的页面中,但是在从powerbi报表获取页面时遇到了问题。

我已经尝试过.load方法,report.getPages()会引发此错误:

ERROR Error: Uncaught (in promise): Object: {"data":"","status":401,"activityId":"xxx","requestId":"yyy","responseRequestId":null,"pendingRequestCount":0}

Screenshot of console error

我的JS是这样的:

tab == null ? 0 : tab;
// call load() instead of embed() to load the report while delaying the rendering process
var report = powerbi.load(embedContainer, config);
// when loaded event occurs, set current page then call render()
report.on("loaded", function () {
    console.log("loaded event executing");
    // call to get Pages collection
    report.getPages().then(
        function (pages) {
        // inspect pages in browser console
        console.log(pages);
        // display specific page in report
        var startPage = pages[1]; // this selects the second page
        config.pageName = startPage.name;
        // Call report.render() to display report
        report.render(config);
    });
});

我希望报表的加载在页面呈现之前,而不是在页面呈现之后。

1 个答案:

答案 0 :(得分:0)

这是一种解决方法,

var embedContainer = $(embedid)[0];
var report = powerbi.embed(embedContainer, config);
if(tab != null) {
    report.on('loaded', function () {
        report.getPages().then(function (pages) {
            pages[tab].setActive();
        });
    });
}

但报告的第一页还是显示