<?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: Ideas on how to programmatically set default selection in custom List Widget in ArcGIS Experience Builder Questions</title>
    <link>https://community.esri.com/t5/arcgis-experience-builder-questions/ideas-on-how-to-programmatically-set-default/m-p/1305154#M7498</link>
    <description>&lt;P&gt;Jeffrey - To follow up on the question.&amp;nbsp; &amp;nbsp;I was able to get the foundation of my code working, by using componentDidUpdate function.&amp;nbsp; &amp;nbsp;I had to add code to make sure the datasource was "Loaded" and not "Loading".&amp;nbsp;&amp;nbsp;datasource.getStatus() === DataSourceStatus.Loading&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Once I was sure the dataSource was loaded, I was able to call SelectRecords, using an appropriate DataRecord.&lt;BR /&gt;&lt;BR /&gt;Now it's time to fill in the rest of the code.&lt;/P&gt;</description>
    <pubDate>Sat, 01 Jul 2023 19:18:23 GMT</pubDate>
    <dc:creator>PaulNRWA</dc:creator>
    <dc:date>2023-07-01T19:18:23Z</dc:date>
    <item>
      <title>Ideas on how to programmatically set default selection in custom List Widget</title>
      <link>https://community.esri.com/t5/arcgis-experience-builder-questions/ideas-on-how-to-programmatically-set-default/m-p/1304977#M7493</link>
      <description>&lt;P&gt;I've created a relatively complex dashboard that represents data across all the states.&amp;nbsp; &amp;nbsp;All my widgets are in-sync and properly update when the user changes selections, etc.&amp;nbsp; &amp;nbsp;I had a request to provide this dashboard, but at the state level only.&amp;nbsp; &amp;nbsp;Since I already have a state list widget setup, I was hoping to use everything that is currently working and simply set the selected state in the list widget.&amp;nbsp; &amp;nbsp;I have the code to determine the state the user is from, but I cannot find a good function to set the default value.&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;I was trying to over-ride the following function, but I'm not sure the right place to call it from during the loading process.&amp;nbsp; &amp;nbsp;Everything I've tried, ends up in an endless loop that throws and error.&lt;BR /&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;private&lt;/SPAN&gt; &lt;SPAN&gt;readonly&lt;/SPAN&gt; &lt;SPAN&gt;selectRecords&lt;/SPAN&gt;&lt;SPAN&gt; = (&lt;/SPAN&gt;&lt;SPAN&gt;records&lt;/SPAN&gt;&lt;SPAN&gt;: &lt;/SPAN&gt;&lt;SPAN&gt;DataRecord&lt;/SPAN&gt;&lt;SPAN&gt;[]) &lt;/SPAN&gt;&lt;SPAN&gt;=&amp;gt;&lt;/SPAN&gt;&lt;SPAN&gt; {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;const&lt;/SPAN&gt;&lt;SPAN&gt; { &lt;/SPAN&gt;&lt;SPAN&gt;datasource&lt;/SPAN&gt;&lt;SPAN&gt; } = &lt;/SPAN&gt;&lt;SPAN&gt;this&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;state&lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;if&lt;/SPAN&gt;&lt;SPAN&gt; (&lt;/SPAN&gt;&lt;SPAN&gt;datasource&lt;/SPAN&gt;&lt;SPAN&gt;) {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;MessageManager&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;getInstance&lt;/SPAN&gt;&lt;SPAN&gt;().&lt;/SPAN&gt;&lt;SPAN&gt;publishMessage&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;new&lt;/SPAN&gt; &lt;SPAN&gt;DataRecordsSelectionChangeMessage&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;this&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;props&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;id&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;records&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; )&lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;if&lt;/SPAN&gt;&lt;SPAN&gt; (&lt;/SPAN&gt;&lt;SPAN&gt;records&lt;/SPAN&gt;&lt;SPAN&gt;) {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;this&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;isMySelected&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;true&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;this&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;isHasPublishMessageAction&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;true&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;datasource&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;selectRecordsByIds&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;records&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;map&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;record&lt;/SPAN&gt; &lt;SPAN&gt;=&amp;gt;&lt;/SPAN&gt; &lt;SPAN&gt;record&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;getId&lt;/SPAN&gt;&lt;SPAN&gt;()))&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;const&lt;/SPAN&gt; &lt;SPAN&gt;outputDs&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;this&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;getOutputDs&lt;/SPAN&gt;&lt;SPAN&gt;()&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;outputDs&lt;/SPAN&gt;&lt;SPAN&gt; &amp;amp;&amp;amp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;outputDs&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;selectRecordsByIds&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;records&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;map&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;record&lt;/SPAN&gt; &lt;SPAN&gt;=&amp;gt;&lt;/SPAN&gt; &lt;SPAN&gt;record&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;getId&lt;/SPAN&gt;&lt;SPAN&gt;()))&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; } &lt;/SPAN&gt;&lt;SPAN&gt;else&lt;/SPAN&gt;&lt;SPAN&gt; {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;this&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;isHasPublishMessageAction&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;false&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; }&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; }&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;I can easily determine the RecordID to set, but I need to figure out where to call this from during the initial load.&amp;nbsp; &amp;nbsp;On a related note, any ideas how to disable the widget programmatically, so the user can switch to see other data?&amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 30 Jun 2023 17:11:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-experience-builder-questions/ideas-on-how-to-programmatically-set-default/m-p/1304977#M7493</guid>
      <dc:creator>PaulNRWA</dc:creator>
      <dc:date>2023-06-30T17:11:19Z</dc:date>
    </item>
    <item>
      <title>Re: Ideas on how to programmatically set default selection in custom List Widget</title>
      <link>https://community.esri.com/t5/arcgis-experience-builder-questions/ideas-on-how-to-programmatically-set-default/m-p/1304986#M7494</link>
      <description>&lt;P&gt;It looks like a class based React component. I would try setting up a componentDidMount() function.&lt;/P&gt;&lt;P&gt;&lt;A href="https://legacy.reactjs.org/docs/react-component.html#componentdidmount" target="_blank"&gt;https://legacy.reactjs.org/docs/react-component.html#componentdidmount&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Jun 2023 17:35:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-experience-builder-questions/ideas-on-how-to-programmatically-set-default/m-p/1304986#M7494</guid>
      <dc:creator>JeffreyThompson2</dc:creator>
      <dc:date>2023-06-30T17:35:20Z</dc:date>
    </item>
    <item>
      <title>Re: Ideas on how to programmatically set default selection in custom List Widget</title>
      <link>https://community.esri.com/t5/arcgis-experience-builder-questions/ideas-on-how-to-programmatically-set-default/m-p/1305085#M7496</link>
      <description>&lt;P&gt;Thanks Jeffrey.&amp;nbsp; &amp;nbsp;I was experimenting with some code in that function and will go back and take a closer look.&amp;nbsp; &amp;nbsp;I agree that it seemed like the logical place to add my code.&lt;/P&gt;</description>
      <pubDate>Fri, 30 Jun 2023 21:14:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-experience-builder-questions/ideas-on-how-to-programmatically-set-default/m-p/1305085#M7496</guid>
      <dc:creator>PaulNRWA</dc:creator>
      <dc:date>2023-06-30T21:14:47Z</dc:date>
    </item>
    <item>
      <title>Re: Ideas on how to programmatically set default selection in custom List Widget</title>
      <link>https://community.esri.com/t5/arcgis-experience-builder-questions/ideas-on-how-to-programmatically-set-default/m-p/1305154#M7498</link>
      <description>&lt;P&gt;Jeffrey - To follow up on the question.&amp;nbsp; &amp;nbsp;I was able to get the foundation of my code working, by using componentDidUpdate function.&amp;nbsp; &amp;nbsp;I had to add code to make sure the datasource was "Loaded" and not "Loading".&amp;nbsp;&amp;nbsp;datasource.getStatus() === DataSourceStatus.Loading&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Once I was sure the dataSource was loaded, I was able to call SelectRecords, using an appropriate DataRecord.&lt;BR /&gt;&lt;BR /&gt;Now it's time to fill in the rest of the code.&lt;/P&gt;</description>
      <pubDate>Sat, 01 Jul 2023 19:18:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-experience-builder-questions/ideas-on-how-to-programmatically-set-default/m-p/1305154#M7498</guid>
      <dc:creator>PaulNRWA</dc:creator>
      <dc:date>2023-07-01T19:18:23Z</dc:date>
    </item>
  </channel>
</rss>

