Forum Discussion
set active page in report with JavaScript API.
- 9 years ago
Thanks Eric_Zhang.
I was able to resolve this and set the page dynamically.
Instead of fetching the page using page name as mentioned in my intial post, I got an array of all the pages and then set whichever page needs to be active.This worked.
My previous code:
const page = report.page(pageName);
page.setActive();My current code:
var pages = [];
report.getPages().then(function (reportPages) {
pages = reportPages;
});pages[1].setActive();
Hope this helps someone visiting here for the same issue.
The simpliest solution is:
var report = powerbi.embed(reportContainer, config);
report.on('loaded', function () {
report.getPages().then(function (pages) {
pages[1].setActive();
});
});
or even simpler in ES6
const report = powerbi.embed(reportContainer, config);
report.on('loaded', () => {
report.getPages().then(pages => pages[1].setActive());
});report.getPages() at the beginning is not working because report itself is not fully loaded yet. Just for people who whant to set a page at the start.
- Anonymous7 years agoNot applicable
the problem is that this is not user friendly, the first page loads ... then gets changed to page x.
I don't understand why the documentation says something and when you can to implement it, it doesn't work.
updateSettings for locale doesn't work also ... :/