- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Determine LayoutType of Embedded PowerBI report
How do I determine whether a report is loaded in MobilePortrait or MobileLandscape via the Javascript API?
I want to add a button on the embedding page that will toggle between mobile and desktop versions of a report.
I can change between the two with the report.updateSettings() function, but I can't figure out how to determine the current settings. Specifically what the layoutType setting is currently set to.
Thanks,
Andy Parkerson
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I figured this out. At load, you can look at the configuration settings, which are stored in the report object.
let report = powerbi.get(document.getElementbyId('embed-container'));
let models = window['powerbi-client'].models;
let isMobile = report.config.settings.layoutType == models.LayoutType.MobilePortrait;
The variable isMobile is a boolean that shows you if the report is mobile or not.
Caution: If you change the layout to MobilePortrait with the report.updateSettings() function, this will no longer work. You could keep track of that in the document at each toggle.
function toggleMobile() {
let settings = document.isMobilePortrait ? {layoutType:window['powerbi-client'].models.LayoutType.MobileLandscape} : {layoutType:window['powerbi-client'].models.LayoutType.MobilePortrait};
report.updateSettings(settings).then(() => {document.isMobilePortrait = !document.isMobilePortrait;});
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I figured this out. At load, you can look at the configuration settings, which are stored in the report object.
let report = powerbi.get(document.getElementbyId('embed-container'));
let models = window['powerbi-client'].models;
let isMobile = report.config.settings.layoutType == models.LayoutType.MobilePortrait;
The variable isMobile is a boolean that shows you if the report is mobile or not.
Caution: If you change the layout to MobilePortrait with the report.updateSettings() function, this will no longer work. You could keep track of that in the document at each toggle.
function toggleMobile() {
let settings = document.isMobilePortrait ? {layoutType:window['powerbi-client'].models.LayoutType.MobileLandscape} : {layoutType:window['powerbi-client'].models.LayoutType.MobilePortrait};
report.updateSettings(settings).then(() => {document.isMobilePortrait = !document.isMobilePortrait;});
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
HI,@andyparkerson
We are delighted that you have found a solution and are willing to share it.
Accepting your post as the solution is incredibly helpful to our community, as it enables members with similar issues to find answers more quickly.
Thank you for your valuable contribution to the community, and we wish you all the best in your work.
Best Regards,
Leroy Lu

Helpful resources
Join us at the Microsoft Fabric Community Conference
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Power BI Monthly Update - February 2025
Check out the February 2025 Power BI update to learn about new features.

Subject | Author | Posted | |
---|---|---|---|
03-01-2024 07:12 AM | |||
01-23-2024 03:16 AM | |||
Anonymous
| 06-04-2024 10:59 PM | ||
07-19-2024 08:24 AM | |||
07-15-2024 12:24 AM |
User | Count |
---|---|
11 | |
3 | |
3 | |
2 | |
2 |
User | Count |
---|---|
18 | |
6 | |
5 | |
3 | |
3 |