<?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 Power BI Custom Visual state persistence in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Power-BI-Custom-Visual-state-persistence/m-p/1660341#M27790</link>
    <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am building a custom table, so basically my table has some expandable/collapsible rows.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using React, so whenever I filter for new data, the expanded rows remain. That's great, expected behavior.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, when I go to another page and come back, the visual re-initializes, which means I lose all the current states.&lt;/P&gt;&lt;P&gt;With default table/matrix, I don't encounter such problems.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there anyway I can persist those states&lt;/P&gt;&lt;P&gt;I know there is a thing called&amp;nbsp;&lt;STRONG&gt;persistProperties,&amp;nbsp;&lt;/STRONG&gt;but AFAIK it persists "Format Pane" only.&lt;/P&gt;&lt;P&gt;Thank you all.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 140px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/452958i774674EC26CC2CC4/image-size/small?v=v2&amp;amp;px=200" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 11 Feb 2021 11:22:19 GMT</pubDate>
    <dc:creator>marrocksd</dc:creator>
    <dc:date>2021-02-11T11:22:19Z</dc:date>
    <item>
      <title>Power BI Custom Visual state persistence</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Power-BI-Custom-Visual-state-persistence/m-p/1660341#M27790</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am building a custom table, so basically my table has some expandable/collapsible rows.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using React, so whenever I filter for new data, the expanded rows remain. That's great, expected behavior.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, when I go to another page and come back, the visual re-initializes, which means I lose all the current states.&lt;/P&gt;&lt;P&gt;With default table/matrix, I don't encounter such problems.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there anyway I can persist those states&lt;/P&gt;&lt;P&gt;I know there is a thing called&amp;nbsp;&lt;STRONG&gt;persistProperties,&amp;nbsp;&lt;/STRONG&gt;but AFAIK it persists "Format Pane" only.&lt;/P&gt;&lt;P&gt;Thank you all.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 140px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/452958i774674EC26CC2CC4/image-size/small?v=v2&amp;amp;px=200" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Feb 2021 11:22:19 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Power-BI-Custom-Visual-state-persistence/m-p/1660341#M27790</guid>
      <dc:creator>marrocksd</dc:creator>
      <dc:date>2021-02-11T11:22:19Z</dc:date>
    </item>
    <item>
      <title>Re: Power BI Custom Visual state persistence</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Power-BI-Custom-Visual-state-persistence/m-p/1661876#M27813</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/284968"&gt;@marrocksd&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;persistProperties&lt;/FONT&gt; is indeed the right way to do this, as React state is lost when the visual is destroyed. The only way to store anything you want persisted in a visual for when it's next instantiated is to use the objects/properties, as the developer visual sandbox prevents cookies and local storage. You would restore the property into your visual state from here when the visual's update method runs and settings are enumerated.&lt;/P&gt;
&lt;P&gt;A property doesn't have to be visible in the pane, but does have to be declared in your &lt;FONT face="courier new,courier"&gt;capabilities.json&lt;/FONT&gt; and available to your &lt;FONT face="courier new,courier"&gt;VisualSettings&lt;/FONT&gt;. However, you can remove that property from the formatting pane during &lt;FONT face="courier new,courier"&gt;enumerateObjectInstances&lt;/FONT&gt; (or, if you are &lt;A href="https://github.com/microsoft/PowerBI-visuals-sampleBarChart/blob/master/src/barChart.ts#L549" target="_self"&gt;manually pushing in the objects, like the sample bar chart&lt;/A&gt;, you can just omit it) so that the user doesn't see it. It will still be present in your visual's objects as a persistable property.&lt;/P&gt;
&lt;P&gt;If your property is a complex object that doesn't fit the data types that &lt;FONT face="courier new,courier"&gt;capabilities.json&lt;/FONT&gt; offers, you can declare a text property in your capabilities and stringify the JSON for storage (and then parse it when settings are enumerated).&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Daniel&lt;/P&gt;</description>
      <pubDate>Fri, 12 Feb 2021 03:44:37 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Power-BI-Custom-Visual-state-persistence/m-p/1661876#M27813</guid>
      <dc:creator>dm-p</dc:creator>
      <dc:date>2021-02-12T03:44:37Z</dc:date>
    </item>
    <item>
      <title>Re: Power BI Custom Visual state persistence</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Power-BI-Custom-Visual-state-persistence/m-p/1662239#M27814</link>
      <description>&lt;P&gt;Thanks alot&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/397"&gt;@dm-p&lt;/a&gt;&amp;nbsp;. I'll try that right now but I believe that's the right way.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have been using useState hook. So it would be easy to add a listener to save and persist all states, then load them as init states next time.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Feb 2021 07:30:56 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Power-BI-Custom-Visual-state-persistence/m-p/1662239#M27814</guid>
      <dc:creator>marrocksd</dc:creator>
      <dc:date>2021-02-12T07:30:56Z</dc:date>
    </item>
    <item>
      <title>Re: Power BI Custom Visual state persistence</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Power-BI-Custom-Visual-state-persistence/m-p/1662375#M27816</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/397"&gt;@dm-p&lt;/a&gt;&amp;nbsp;, one other thing. It's about when to persist the state.&lt;/P&gt;&lt;P&gt;Currently I'm persisting all states everytime the user expands or collapses a row... sound not good for performance at all.&lt;/P&gt;&lt;P&gt;I've tried:&lt;/P&gt;&lt;P&gt;&amp;nbsp;- public destroy() method in Visual class&lt;/P&gt;&lt;P&gt;&amp;nbsp;- public componentWillUnmount method in Visual class&lt;/P&gt;&lt;P&gt;&amp;nbsp;- React useEffect(... return...) in my component&lt;/P&gt;&lt;P&gt;None works, could you help me please, thanks a ton&lt;/P&gt;</description>
      <pubDate>Fri, 12 Feb 2021 08:13:25 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Power-BI-Custom-Visual-state-persistence/m-p/1662375#M27816</guid>
      <dc:creator>marrocksd</dc:creator>
      <dc:date>2021-02-12T08:13:25Z</dc:date>
    </item>
  </channel>
</rss>

