<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Power BI MVC - Help with Mobile views in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Power-BI-MVC-Help-with-Mobile-views/m-p/2263253#M33708</link>
    <description>&lt;P&gt;Hi v-shex-msft and a happy new year!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The uploaded report has a mobile view which was created in powerbi desktop.&lt;/P&gt;</description>
    <pubDate>Mon, 03 Jan 2022 07:25:41 GMT</pubDate>
    <dc:creator>s_papaioannou</dc:creator>
    <dc:date>2022-01-03T07:25:41Z</dc:date>
    <item>
      <title>Power BI MVC - Help with Mobile views</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Power-BI-MVC-Help-with-Mobile-views/m-p/2258156#M33635</link>
      <description>&lt;P&gt;Hello everybody! I hope you are doing well!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We have created a new MVC app where we embed PowerBI Reports.&lt;/P&gt;&lt;P&gt;We have used the sample 'App Owns Data' project to utilize it and we managed to get the project working.&lt;/P&gt;&lt;P&gt;Now we are looking into further customising the app by getting the the view in desktop and mobile. So we have created a mobile portrait view of the report and we would like our app to check the device from which the report is being viewed and serve the correspending view. I have tried with multiple ways I found on the net, but with no success. I will just paste the 4 different samples i found and tried out but with no success.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any insight on this will be greatly appriciated.&lt;/P&gt;&lt;P&gt;Thank you in advance&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PS The code tag Javascript threw some errors while pasting the code in it and i could not post the code formated decently. Sorry about that&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;////////////////////////////////////// Method 1&lt;BR /&gt;let isMobile = window.matchMedia("only screen and (max-width: 760px)").matches;&lt;BR /&gt;let newSettings = {&lt;BR /&gt;layoutType: models.LayoutType.MobilePortrait&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;if (isMobile) { //this returns true or false&lt;BR /&gt;newSettings = {&lt;BR /&gt;layoutType: models.LayoutType.MobilePortrait&lt;BR /&gt;};&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;////////////////////////////////////// Method 2&lt;BR /&gt;var embedConfiguration = {&lt;BR /&gt;type: 'report',&lt;BR /&gt;id: reportId,&lt;BR /&gt;embedUrl: embedUrl,&lt;BR /&gt;tokenType: tokenType,&lt;BR /&gt;accessToken: accessToken,&lt;BR /&gt;settings: {&lt;BR /&gt;layoutType: models.LayoutType.MobilePortrait&lt;BR /&gt;}&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/////////////////////////////////////////// Method 3&lt;BR /&gt;//Retrieve the page collection and check if the first page has a MobilePortrait layout.&lt;BR /&gt;try {&lt;BR /&gt;const pages = await report.getPages();&lt;BR /&gt;const hasLayout = await pages[0].hasLayout(models.LayoutType.MobilePortrait);&lt;/P&gt;&lt;P&gt;let hasLayoutText = hasLayout ? "has" : "doesn't have";&lt;BR /&gt;console.log("Page \"" + pages[0].name + "\" " + hasLayoutText + " mobile portrait layout.");&lt;BR /&gt;}&lt;BR /&gt;catch (errors) {&lt;BR /&gt;console.log(errors);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;//////////////////////////// Method 4&lt;/P&gt;&lt;P&gt;window.addEventListener('resize', async () =&amp;gt; {&lt;BR /&gt;//write a function to detect the screen size&lt;BR /&gt;let isMobile = await isMobileScreen();&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;let newSettings = {&lt;BR /&gt;layoutType: models.LayoutType.MobileLandscape&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;if (isMobile) { //this returns true or false&lt;BR /&gt;newSettings = {&lt;BR /&gt;layoutType: models.LayoutType.MobilePortrait&lt;BR /&gt;};&lt;BR /&gt;report.updateSettings(newSettings);//update the report settings&lt;BR /&gt;} else {&lt;BR /&gt;report.updateSettings(newSettings); //update the report settings&lt;BR /&gt;}&lt;BR /&gt;});Any insight on this will be greatly appriciated&lt;/P&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Dec 2021 10:27:29 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Power-BI-MVC-Help-with-Mobile-views/m-p/2258156#M33635</guid>
      <dc:creator>s_papaioannou</dc:creator>
      <dc:date>2021-12-28T10:27:29Z</dc:date>
    </item>
    <item>
      <title>Re: Power BI MVC - Help with Mobile views</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Power-BI-MVC-Help-with-Mobile-views/m-p/2261677#M33682</link>
      <description>&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;HI&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/348374"&gt;@s_papaioannou&lt;/a&gt;,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;How did you design the report phone view version? Did you mean to manually change the layout to vertical?&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;If that is the case, they may not work well as phone views. (it only mean the report with vertical layout instead of phone view) &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;For this scenario, I'd like to suggest you refer to the following documents to design the phone view version and enable the phone view on your report:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;&lt;A href="https://docs.microsoft.com/en-us/power-bi/create-reports/desktop-create-phone-report?tabs=powerbi-desktop" target="_blank" rel="noopener"&gt;Optimize reports for the Power BI mobile apps - Power BI | Microsoft Docs&lt;/A&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;&lt;A href="https://docs.microsoft.com/en-us/javascript/api/overview/powerbi/mobile" target="_blank"&gt;Embedding a Power BI report with mobile layout in Power BI embedded analytics | Microsoft Docs&lt;/A&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;Regards,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;Xiaoxin Sheng&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 31 Dec 2021 01:21:20 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Power-BI-MVC-Help-with-Mobile-views/m-p/2261677#M33682</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-12-31T01:21:20Z</dc:date>
    </item>
    <item>
      <title>Re: Power BI MVC - Help with Mobile views</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Power-BI-MVC-Help-with-Mobile-views/m-p/2263253#M33708</link>
      <description>&lt;P&gt;Hi v-shex-msft and a happy new year!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The uploaded report has a mobile view which was created in powerbi desktop.&lt;/P&gt;</description>
      <pubDate>Mon, 03 Jan 2022 07:25:41 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Power-BI-MVC-Help-with-Mobile-views/m-p/2263253#M33708</guid>
      <dc:creator>s_papaioannou</dc:creator>
      <dc:date>2022-01-03T07:25:41Z</dc:date>
    </item>
    <item>
      <title>Re: Power BI MVC - Help with Mobile views</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Power-BI-MVC-Help-with-Mobile-views/m-p/2266756#M33759</link>
      <description>&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;HI&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/348374"&gt;@s_papaioannou&lt;/a&gt;,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;Perhaps you can take a look at the following link about the online power bi embedded online sandbox testing environments. It should include a sample code of embedded usages which you required:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;&lt;A href="https://playground.powerbi.com/" target="_blank"&gt;Power BI Embedded Playground&lt;/A&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;Regards,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;Xiaoxin Sheng&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jan 2022 06:46:55 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Power-BI-MVC-Help-with-Mobile-views/m-p/2266756#M33759</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-01-05T06:46:55Z</dc:date>
    </item>
    <item>
      <title>Re: Power BI MVC - Help with Mobile views</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Power-BI-MVC-Help-with-Mobile-views/m-p/2266852#M33760</link>
      <description>&lt;P&gt;Thank you for the information. I have already taken a look at the Developer Playground and I have pasted the sample code I used from the Playground in my initial post.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jan 2022 07:49:43 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Power-BI-MVC-Help-with-Mobile-views/m-p/2266852#M33760</guid>
      <dc:creator>s_papaioannou</dc:creator>
      <dc:date>2022-01-05T07:49:43Z</dc:date>
    </item>
    <item>
      <title>Re: Power BI MVC - Help with Mobile views</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Power-BI-MVC-Help-with-Mobile-views/m-p/2283185#M33877</link>
      <description>&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;HI&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/348374"&gt;@s_papaioannou&lt;/a&gt;,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;Perhaps you can take a look at the following link about mobile device detection with ASP.NET MVC applications if help:&amp;nbsp;&lt;/FONT&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;&lt;A href="https://www.codeguru.com/dotnet/mobile-device-detection-and-redirection-using-asp-net-mvc/" target="_blank"&gt;Mobile Device Detection and Redirection Using ASP.NET/MVC | CodeGuru&lt;/A&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;After you get the access device type, you can use it as if statement conditions to trigger the configuration to switch the report to 'phone view' mode.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;Regards,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;Xiaxoin Sheng&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jan 2022 07:18:20 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Power-BI-MVC-Help-with-Mobile-views/m-p/2283185#M33877</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-01-14T07:18:20Z</dc:date>
    </item>
  </channel>
</rss>

