Reputation: 471
I am trying to implement some custom page navigation per report in Power BI. I am trying to get a list of the pages for the report so I can loop through those pages in custom tabs of mine. report.getPages().then(pages => { console.log("in the getpages .then"); console.log(pages)return pages; });
This is my code and I'm not sure why, once the promise resolves, I'm not able to log the pages. Any help on this is appreciated. Thank you!
Upvotes: 0
Views: 773
Reputation: 3024
I just tested this functionality using the Power BI Embedded Playground -> Sample Report, which is a great way to test SDK functions.
The following snippet is functional and provided by the Power BI Embedded Playground.
// Get a reference to the embedded report HTML element
var embedContainer = $('#embedContainer')[0];
// Get a reference to the embedded report.
report = powerbi.get(embedContainer);
// Retrieve the page collection and loop through to collect the
// page name and display name of each page and display the value.
report.getPages()
.then(function (pages) {
var log = "Report pages:";
pages.forEach(function (page) {
log += "\n" + page.name + " - " + page.displayName;
});
Log.logText(log);
})
.catch(function (error) {
Log.log(error);
});
> Loaded
> Report pages:
> ReportSectioneb8c865100f8508cc533 - Tiles
ReportSection600dd9293d71ade01765 - Market Share
ReportSectiona271643cba2213c935be - YTD Category
ReportSection1c45b5dc6513ae89b4e3 - Sentiment
ReportSection2ff5a27ac612830bbd93 - Tooltip
ReportSection6da8317ad6cbcae5b3bb - Empty Page
> Rendered
Upvotes: 1