如何在使用iFrame嵌入Power BI报表时隐藏“页面”和“过滤器”

时间:2020-01-29 09:20:54

标签: powerbi powerbi-embedded powerbi-filters

我正在尝试使用iframe将Power BI报表嵌入到我的网页中,但是它在网页中显示该报表的页面名称和右侧过滤器,我们可以同时隐藏该报表的页面名称和过滤器吗? / p>

2 个答案:

答案 0 :(得分:1)

您可以配置报告的设置。将以下标志设置为false,以实现所需的设置。

settings: {
  filterPaneEnabled: false,
  navContentPaneEnabled: false
}

您可以在此处阅读有关内容:
https://github.com/Microsoft/PowerBI-JavaScript/wiki/Embed-Configuration-Details

答案 1 :(得分:1)

如另一个答案所述,如果您使用的是PowerBI JavaScript API,则可以尝试传入这些参数 https://github.com/microsoft/PowerBI-JavaScript

settings: {
  filterPaneEnabled: false,
  navContentPaneEnabled: false
}

文档: https://github.com/Microsoft/PowerBI-JavaScript/wiki/Embed-Configuration-Details

如果失败,您可以尝试像这样操作iframe的DOM:

<!DOCTYPE html>
<html>

<body>

    <iframe id="myframe" src="demo_iframe.htm"></iframe>

    <p>Click the button to change the background color of the document contained in the iframe.</p>

    <p id="demo"></p>

    <button onclick="myFunction()">Try it</button>

    <script>
        function myFunction() {
            var x = document.getElementById("myframe");
            var y = (x.contentWindow || x.contentDocument);
            if (y.document) y = y.document;
            y.body.style.backgroundColor = "red";
        }
    </script>

</body>

</html>

您可以在此处查看演示:
https://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_iframe_contentdocument

,并在此进行解释:
https://www.w3schools.com/jsref/prop_frame_contentdocument.asp