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 documentaion introduces the feature as you did in your code, however I'm not able to set a default page as well.
Based on my search, there's an online demo, which shows this feature actually working.
You can check what the demo does in the js file
https://microsoft.github.io/PowerBI-JavaScript/demo/app/defaults.js
I'm researching on this and would share any update I get.
- skancharla9 years ago
Advocate II
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.
- daweins8 years agoRegular Visitor
Resurrecting this old post, but I hit this myself, and found a reasonable solution. The pageName setting does work, but the value required is not the "display name" you see in PowerBI, but actually an internal section ID. You can get this value by accessing the report in the web version of PowerBI and examining the URL.
Ex, for my report below, my groupID is b5801...a4f, my reportID is 634f...054b, and my pageName is ReportSection50033...a22cWhile a little ugly, this lets you skip a double page load - I was having trouble with your solution above, as it's dependent on the timing of the report load. I achieved a workable solution by putting the page setter in a report loaded event, but I didn't like the user experience, as the default page (whatever I happened to edit last) would have to load before the desired page would load. Using the direct method with the internal ReportSection{ID} worked a lot cleaner.
- Anonymous7 years agoNot applicable
Thanks for sharing. This works for me perfectly.
Also, for someone who has the same issue with bookmark, I'd like to add that the bookmark setting works the same way! Bookmark name setting just doesn't work when loading. I've been searching for the solutions. And it finally worked when I tried also with the GUID in the url, instead of the bookmark name. Like this
embedConfig={
...
'bookmark':{
"name":"Bookmarkfdc07f*******120"
}You can get the GUID in the url with your target bookmark on.
app.powerbi.com/groups/.../ReportSectiond...?bookmarkGuid=Bookmark6...1
- bensalemc8 years agoNew Member
Hello,
I'm facing the same problem and this is not working for me.
I get an error saying "Property 'getPages' does not exist on type 'Embed'."
Do you have any idea how to solve this?
Thank you.
Cyrine. - Anonymous3 years agoNot applicable
Great response!
Setting the active page is required in order to use:await visual.getSlicerState() since this request only works with the active page.
Thank you.
Vincent