<?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: Typescript API: switchMode in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Typescript-API-switchMode/m-p/392317#M11660</link>
    <description>&lt;P&gt;Submitted a pull Request&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/Microsoft/powerbi-models/pull/58" target="_blank"&gt;https://github.com/Microsoft/powerbi-models/pull/58&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 09 Apr 2018 11:32:05 GMT</pubDate>
    <dc:creator>Ameb</dc:creator>
    <dc:date>2018-04-09T11:32:05Z</dc:date>
    <item>
      <title>Typescript API: switchMode</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Typescript-API-switchMode/m-p/392307#M11658</link>
      <description>&lt;P&gt;On powebi-models there is a &lt;A href="https://github.com/Microsoft/powerbi-models/blob/baaaf184d4966b09094a2539a538bf10c6cb69c4/src/models.ts#L123" target="_self"&gt;enum&lt;/A&gt;&amp;nbsp;defined as viewMode, which is used in the definition of &lt;A href="https://github.com/Microsoft/PowerBI-JavaScript/blob/9bc5f4519129949aeb397e1cd7aa52e80bb75074/dist/powerbi-client.d.ts#L849" target="_self"&gt;switchMode&lt;/A&gt;. But the &lt;A href="https://github.com/Microsoft/PowerBI-JavaScript/blob/9bc5f4519129949aeb397e1cd7aa52e80bb75074/src/report.ts#L332" target="_self"&gt;implementation&amp;nbsp;i&lt;/A&gt;s inconsistent&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;  /**
   * Switch Report view mode.
   *
   * @returns {Promise&amp;lt;void&amp;gt;}
   */
  switchMode(viewMode: models.ViewMode): Promise&amp;lt;void&amp;gt; {
    let url = '/report/switchMode/' + viewMode;
    return this.service.hpm.post&amp;lt;models.IError[]&amp;gt;(url, null, { uid: this.config.uniqueId }, this.iframe.contentWindow)
      .then(response =&amp;gt; {
        return response.body;
      })
      .catch(response =&amp;gt; {
        throw response.body;
      });
  }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As viewMode is an enum, this expression translates into&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;/report/switchMode/0 or /report/switchMode/1&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It makes no sense since the API endpoint expects 'view' or 'edit', as seen in the &lt;A href="https://github.com/Microsoft/PowerBI-JavaScript/blob/master/demo/v2-demo/scripts/codesamples.js" target="_self"&gt;code examples&lt;/A&gt;:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;function _Report_switchModeEdit() {
    // Get a reference to the embedded report HTML element
    var embedContainer = $('#embedContainer')[0];

    // Get a reference to the embedded report.
    report = powerbi.get(embedContainer);

    // Switch to edit mode.
    report.switchMode("edit");
}

function _Report_switchModeView() {
    // Get a reference to the embedded report HTML element
    var embedContainer = $('#embedContainer')[0];

    // Get a reference to the embedded report.
    report = powerbi.get(embedContainer);

    // Switch to view mode.
    report.switchMode("view");
}&amp;nbsp;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So either the type definitions or the implementation should be fixed.&lt;/P&gt;</description>
      <pubDate>Mon, 09 Apr 2018 11:11:41 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Typescript-API-switchMode/m-p/392307#M11658</guid>
      <dc:creator>Ameb</dc:creator>
      <dc:date>2018-04-09T11:11:41Z</dc:date>
    </item>
    <item>
      <title>Re: Typescript API: switchMode</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Typescript-API-switchMode/m-p/392317#M11660</link>
      <description>&lt;P&gt;Submitted a pull Request&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/Microsoft/powerbi-models/pull/58" target="_blank"&gt;https://github.com/Microsoft/powerbi-models/pull/58&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Apr 2018 11:32:05 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Typescript-API-switchMode/m-p/392317#M11660</guid>
      <dc:creator>Ameb</dc:creator>
      <dc:date>2018-04-09T11:32:05Z</dc:date>
    </item>
    <item>
      <title>Re: Typescript API: switchMode</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Typescript-API-switchMode/m-p/690666#M19383</link>
      <description>&lt;P&gt;This is fixed.&lt;/P&gt;&lt;P&gt;swithcMode now takes an enum or a string.&lt;/P&gt;&lt;P&gt;&lt;SPAN class="mtk1"&gt;Report.switchMode(viewMode: string &lt;/SPAN&gt;&lt;SPAN class="mtk11"&gt;|&lt;/SPAN&gt;&lt;SPAN class="mtk1"&gt; ViewMode)&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 14 May 2019 10:44:47 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Typescript-API-switchMode/m-p/690666#M19383</guid>
      <dc:creator>alihm</dc:creator>
      <dc:date>2019-05-14T10:44:47Z</dc:date>
    </item>
  </channel>
</rss>

