Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
ajelcocks
Frequent Visitor

page events not firing

I have installed powerbi report server developer edition locally per instructions here https://docs.microsoft.com/en-us/power-bi/report-server/install-report-server

I downloaded power bi desktop fior RS per the instructions

Then I created a simple report.

Finally I created a very simple web page in VS Code and launched it using lite-server. 

 

html is:

<html>
  <head>
    <script src="./dist/powerbi.js"></script>
    <script src="./dist/bundle.js"></script>
  </head>
  <body>
    <h3>powerbi lite</h3>
    <button id="pageButton">getPage</button>
    <div id="charts">charts</div>
  </body>
</html>
 
javascript is
 
window.onload = start;

const PBI_URL = "http://localhost:4010/powerbi/";
const REPORT_ID = "39af5e1d-c919-4594-ad6a-ee772f734d3d";

let reportUrl = `${PBI_URL}?rs:embed=true&id=${REPORT_ID}&formatLocale=en-US`;

function start() {
  let container = document.getElementById("charts");
  let models = window["powerbi-client"].models;

  var config = {
    type: "report",
    tokenType: models.TokenType.Embed,
    accessToken: "123",
    embedUrl: reportUrl,
    id: REPORT_ID,
    permissions: models.Permissions.All,
    settings: {
      filterPaneEnabled: true,
      navContentPaneEnabled: true
    }
  };

  let report = window.powerbi.embed(containerconfig);

  report.on("loaded"function() {
    console.log("Report loaded");
  });

  document.getElementById("pageButton").onclick = getPage;
}

function getPage() {
  let container = document.getElementById("charts");
  let report = window.powerbi.get(container);
  report.eventHandlers[0].handle();
  report.getPages().then(function(pages) {
    console.log(pages);
  });
 
}
The page loades in a iframe created in the container, as expected, but the loaded event doesnt fire.
 
I also add a button as a trigger to invoke some code manually, i.e. function getPage()
 
This shows the handler was added as the invocation of handle() prints to console.
 
However, The promise of report.getPages() does not fire.
 
It seems none of the mesages pushed are firing.
I ran fiddler and no api calls are registered when I click the button.
 
Does anyone have experience with this? or knowledge of a resource I can leverage?
Thanks 🙂
0 REPLIES 0

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.