<?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 Listen to to records changes in FeatureLayerDatasource in ArcGIS Experience Builder Questions</title>
    <link>https://community.esri.com/t5/arcgis-experience-builder-questions/listen-to-to-records-changes-in/m-p/1220325#M5469</link>
    <description>&lt;P&gt;I'm using ArcGIS Experience Builder 1.5. I'm developing a custom widget with a FeatureLayerDataSource. I can use the&amp;nbsp;FeatureLayerDataSource selected Records. When I select some features in a the map widget this records change. But I don't understand how I can listen/connect to an event when the the selected records changes? This must be a very basic problem but don't have a clue&amp;nbsp;&lt;SPAN&gt;it is supposed&amp;nbsp;&lt;/SPAN&gt;to work.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 10 Oct 2022 12:07:25 GMT</pubDate>
    <dc:creator>Zoggo</dc:creator>
    <dc:date>2022-10-10T12:07:25Z</dc:date>
    <item>
      <title>Listen to to records changes in FeatureLayerDatasource</title>
      <link>https://community.esri.com/t5/arcgis-experience-builder-questions/listen-to-to-records-changes-in/m-p/1220325#M5469</link>
      <description>&lt;P&gt;I'm using ArcGIS Experience Builder 1.5. I'm developing a custom widget with a FeatureLayerDataSource. I can use the&amp;nbsp;FeatureLayerDataSource selected Records. When I select some features in a the map widget this records change. But I don't understand how I can listen/connect to an event when the the selected records changes? This must be a very basic problem but don't have a clue&amp;nbsp;&lt;SPAN&gt;it is supposed&amp;nbsp;&lt;/SPAN&gt;to work.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Oct 2022 12:07:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-experience-builder-questions/listen-to-to-records-changes-in/m-p/1220325#M5469</guid>
      <dc:creator>Zoggo</dc:creator>
      <dc:date>2022-10-10T12:07:25Z</dc:date>
    </item>
    <item>
      <title>Re: Listen to to records changes in FeatureLayerDatasource</title>
      <link>https://community.esri.com/t5/arcgis-experience-builder-questions/listen-to-to-records-changes-in/m-p/1233676#M5793</link>
      <description>&lt;P&gt;You can use &lt;A href="https://developers.arcgis.com/experience-builder/api-reference/jimu-core/DataSourceComponent" target="_self"&gt;DataSourceComponent&lt;/A&gt;, it's to help create data source instance, load records and listen changes (selection change, filter change and so on.) of data source.&lt;/P&gt;&lt;P&gt;1. Use DataSourceComponent to create data source instance and load records.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;&amp;lt;DataSourceComponent useDataSource={props.useDataSources[0]} query={{ where: '1=1' } as FeatureLayerQueryParams} widgetId={props.id}&amp;gt;
  {dataRender}
&amp;lt;/DataSourceComponent&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;2. U&lt;SPAN&gt;se render function (dataRender in above sample code) of DataSourceComponent, the render function will be called whenever the data source info change (e.g. selection change) or loaded records change (e.g. other widgets apply a filter to the data source).&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const dataRender = (ds: DataSource, info: IMDataSourceInfo) =&amp;gt; {
  return &amp;lt;div className='record-list'&amp;gt;
      {
        ds &amp;amp;&amp;amp; ds.getStatus() === DataSourceStatus.Loaded
          ? ds.getRecords().map((r, i) =&amp;gt; {
            // select a record on click and add blue border when a record is clicked (by any widgets)
            return &amp;lt;Button type='tertiary' key={i} onClick={() =&amp;gt; ds.selectRecordById(r.getId())} className={classNames({ 'blue-border': ds.getSelectedRecordIds()?.includes(r.getId()) })}&amp;gt;
              {r.getId()}
            &amp;lt;/Button&amp;gt;
          })
          : null
      }
    &amp;lt;/div&amp;gt;
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Nov 2022 09:06:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-experience-builder-questions/listen-to-to-records-changes-in/m-p/1233676#M5793</guid>
      <dc:creator>YueyangLi</dc:creator>
      <dc:date>2022-11-21T09:06:30Z</dc:date>
    </item>
  </channel>
</rss>

