<?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: Detecting selection event on Query or Attribute Table widgets in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/detecting-selection-event-on-query-or-attribute/m-p/607004#M56776</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Robert, thanks for your review.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Finally I implemented the third option overriding the original methods where the widgets manage the query results. And It works fine!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My code for Query widget....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="font-size: 13px;"&gt;var widgetConfigs = null;&lt;/SPAN&gt;

&lt;SPAN style="font-size: 13px;"&gt;if ((widgetConfigs = widget.appConfig.getConfigElementsByName("Query")) != null &amp;amp;&amp;amp; widgetConfigs.length &amp;gt; 0) {&lt;/SPAN&gt;
&lt;SPAN style="font-size: 13px;"&gt;&amp;nbsp; var connectFunction = null;&lt;/SPAN&gt;
&lt;SPAN style="font-size: 13px;"&gt;&amp;nbsp; var queryWidget = widget.widgetManager.getWidgetById(widgetConfigs[0].id);&lt;/SPAN&gt;

&lt;SPAN style="font-size: 13px;"&gt;&amp;nbsp; // ... override methods.&lt;/SPAN&gt;
&lt;SPAN style="font-size: 13px;"&gt;&amp;nbsp; connectFunction = function (currentWidget) {&lt;/SPAN&gt;
&lt;SPAN style="font-size: 13px;"&gt;&amp;nbsp; &amp;nbsp; var theWidget = currentWidget;&lt;/SPAN&gt;
&lt;SPAN style="font-size: 13px;"&gt;&amp;nbsp; &amp;nbsp; var theOriginalResultItemsFunction = theWidget._addResultItems;&lt;/SPAN&gt;
&lt;SPAN style="font-size: 13px;"&gt;&amp;nbsp; &amp;nbsp; var theOriginalClearResultPageFunction = theWidget._clearResultPage;&lt;/SPAN&gt;

&lt;SPAN style="font-size: 13px;"&gt;&amp;nbsp; &amp;nbsp; if (!theOriginalResultItemsFunction || !theOriginalClearResultPageFunction)&lt;/SPAN&gt;
&lt;SPAN style="font-size: 13px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;return;&lt;/SPAN&gt;

&lt;SPAN style="font-size: 13px;"&gt;&amp;nbsp; &amp;nbsp; theWidget._addResultItems = function (features, resultLayer, relatedResults, relatedTableIds) {&lt;/SPAN&gt;
&lt;SPAN style="font-size: 13px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;var self = this;&lt;/SPAN&gt;
&lt;SPAN style="font-size: 13px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;theOriginalResultItemsFunction.call(self, features, resultLayer, relatedResults, relatedTableIds);&lt;/SPAN&gt;

&lt;SPAN style="font-size: 13px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;... my bla bla&lt;/SPAN&gt;
&lt;SPAN style="font-size: 13px;"&gt;&amp;nbsp; &amp;nbsp; };&lt;/SPAN&gt;
&lt;SPAN style="font-size: 13px;"&gt;&amp;nbsp; &amp;nbsp; theWidget._clearResultPage = function () {&lt;/SPAN&gt;
&lt;SPAN style="font-size: 13px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;var self = this;&lt;/SPAN&gt;
&lt;SPAN style="font-size: 13px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;theOriginalClearResultPageFunction.call(self);&lt;/SPAN&gt;

&lt;SPAN style="font-size: 13px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;... my bla bla&lt;/SPAN&gt;
&lt;SPAN style="font-size: 13px;"&gt;&amp;nbsp; &amp;nbsp; };&lt;/SPAN&gt;
&lt;SPAN style="font-size: 13px;"&gt;&amp;nbsp; };&lt;/SPAN&gt;
&lt;SPAN style="font-size: 13px;"&gt;&amp;nbsp; if (!queryWidget) {&lt;/SPAN&gt;
&lt;SPAN style="font-size: 13px;"&gt;&amp;nbsp; &amp;nbsp; widget.widgetManager.loadWidget(widgetConfigs[0]).then(lang.hitch(widget, function (currentWidget) { connectFunction(currentWidget); }));&lt;/SPAN&gt;
&lt;SPAN style="font-size: 13px;"&gt;&amp;nbsp; }&lt;/SPAN&gt;
&lt;SPAN style="font-size: 13px;"&gt;&amp;nbsp; else {&lt;/SPAN&gt;
&lt;SPAN style="font-size: 13px;"&gt;&amp;nbsp; &amp;nbsp; connectFunction(queryWidget);&lt;/SPAN&gt;
&lt;SPAN style="font-size: 13px;"&gt;&amp;nbsp; }&lt;/SPAN&gt;
&lt;SPAN style="font-size: 13px;"&gt; }&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; Thanks Robert!&lt;/P&gt;&lt;P&gt;Alvaro&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 16:41:23 GMT</pubDate>
    <dc:creator>ahuarte</dc:creator>
    <dc:date>2021-12-12T16:41:23Z</dc:date>
    <item>
      <title>Detecting selection event on Query or Attribute Table widgets</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/detecting-selection-event-on-query-or-attribute/m-p/607000#M56772</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&amp;nbsp;&lt;SPAN style="background-color: #ffffff;"&gt;I'm trying to find a way to detect the event of feature selection of a&amp;nbsp;&lt;SPAN style="color: #c41a16;"&gt;ArcGISMapServiceLayer&amp;nbsp;&lt;SPAN style="color: #3d3d3d; background-color: #ffffff;"&gt;loaded in a map. Or get the features selected by user using the Query or Attribute Table widgets.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't know how to get the FeatureLayer collection of the ArcGISMapServiceLayer&amp;nbsp;instance to attach their 'selection-change'/'selection-clear' events. I see the 'layersInfo' member successfully but the method 'map.getLayer(id)' always return null to these sublayer collection.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Is it possible? How&amp;nbsp;I do it?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks in advance&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Alvaro&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Nov 2016 12:29:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/detecting-selection-event-on-query-or-attribute/m-p/607000#M56772</guid>
      <dc:creator>ahuarte</dc:creator>
      <dc:date>2016-11-10T12:29:18Z</dc:date>
    </item>
    <item>
      <title>Re: Detecting selection event on Query or Attribute Table widgets</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/detecting-selection-event-on-query-or-attribute/m-p/607001#M56773</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;Alvaro,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;&amp;nbsp; &amp;nbsp;A&amp;nbsp;&lt;SPAN&gt;ArcGISMapServiceLayer is just an image from the server and does not have geometries returned to the map. The query widget and the AT widget are able to select features because they use a QueryTask on the map service or create a FeatureLayer fro the query results. The query widget adds the QueryTask results as a FeatureLayer using a FeatureCollection.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Nov 2016 17:48:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/detecting-selection-event-on-query-or-attribute/m-p/607001#M56773</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2016-11-10T17:48:58Z</dc:date>
    </item>
    <item>
      <title>Re: Detecting selection event on Query or Attribute Table widgets</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/detecting-selection-event-on-query-or-attribute/m-p/607002#M56774</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Robert, sorry I wrote a wrong name class, I have a&amp;nbsp;&lt;SPAN style="color: #636363; background-color: #fefefe;"&gt;ArcGISDynamicMapServiceLayer instance. Its&amp;nbsp;&lt;A href="https://developers.arcgis.com/javascript/3/jsapi/arcgisdynamicmapservicelayer-amd.html#layerinfos"&gt;layerinfos&lt;/A&gt;&amp;nbsp;member contains the layers I want attach, but I looked that AT and Query widgets create their own "private" FeatureLayer and&amp;nbsp;&lt;SPAN style="color: #3d3d3d; background-color: #ffffff;"&gt;QueryTask instances.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff; color: #3d3d3d;"&gt;I see four&amp;nbsp;options:&lt;/SPAN&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;SPAN style="background-color: #ffffff; color: #3d3d3d;"&gt;Edit these widgets to&amp;nbsp;emit 'selection' events using&amp;nbsp;map as target, and I attach them in my own widget.&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN style="background-color: #ffffff; color: #3d3d3d;"&gt;&lt;SPAN&gt;Edit these widgets to use the&amp;nbsp;publishData/onReceiveData comunication.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN style="background-color: #ffffff; color: #3d3d3d;"&gt;Override some methods of these widgets in my own widget to avoid edit the original code adding my own emit events.&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN style="background-color: #ffffff; color: #3d3d3d;"&gt;Override the FeatureLayer constructor in my widget to attach any instance created in any widget of the application and then to attach the 'selection-complete'/'selection-clear' events of FeatureLayers with a specific url.&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff; color: #3d3d3d;"&gt;First and second options force to me to deploy new "rewrited" widgets, I don't like it &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 Nov 2016 08:57:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/detecting-selection-event-on-query-or-attribute/m-p/607002#M56774</guid>
      <dc:creator>ahuarte</dc:creator>
      <dc:date>2016-11-11T08:57:06Z</dc:date>
    </item>
    <item>
      <title>Re: Detecting selection event on Query or Attribute Table widgets</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/detecting-selection-event-on-query-or-attribute/m-p/607003#M56775</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;Alvaro,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;&amp;nbsp; &amp;nbsp;I have looked into this a few minutes and all I can say is you have your work cut out for you. Option 1 and 2 are definitely the easy route initially but like you said maintainability. Good luck on this venture.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 Nov 2016 20:48:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/detecting-selection-event-on-query-or-attribute/m-p/607003#M56775</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2016-11-11T20:48:44Z</dc:date>
    </item>
    <item>
      <title>Re: Detecting selection event on Query or Attribute Table widgets</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/detecting-selection-event-on-query-or-attribute/m-p/607004#M56776</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Robert, thanks for your review.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Finally I implemented the third option overriding the original methods where the widgets manage the query results. And It works fine!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My code for Query widget....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="font-size: 13px;"&gt;var widgetConfigs = null;&lt;/SPAN&gt;

&lt;SPAN style="font-size: 13px;"&gt;if ((widgetConfigs = widget.appConfig.getConfigElementsByName("Query")) != null &amp;amp;&amp;amp; widgetConfigs.length &amp;gt; 0) {&lt;/SPAN&gt;
&lt;SPAN style="font-size: 13px;"&gt;&amp;nbsp; var connectFunction = null;&lt;/SPAN&gt;
&lt;SPAN style="font-size: 13px;"&gt;&amp;nbsp; var queryWidget = widget.widgetManager.getWidgetById(widgetConfigs[0].id);&lt;/SPAN&gt;

&lt;SPAN style="font-size: 13px;"&gt;&amp;nbsp; // ... override methods.&lt;/SPAN&gt;
&lt;SPAN style="font-size: 13px;"&gt;&amp;nbsp; connectFunction = function (currentWidget) {&lt;/SPAN&gt;
&lt;SPAN style="font-size: 13px;"&gt;&amp;nbsp; &amp;nbsp; var theWidget = currentWidget;&lt;/SPAN&gt;
&lt;SPAN style="font-size: 13px;"&gt;&amp;nbsp; &amp;nbsp; var theOriginalResultItemsFunction = theWidget._addResultItems;&lt;/SPAN&gt;
&lt;SPAN style="font-size: 13px;"&gt;&amp;nbsp; &amp;nbsp; var theOriginalClearResultPageFunction = theWidget._clearResultPage;&lt;/SPAN&gt;

&lt;SPAN style="font-size: 13px;"&gt;&amp;nbsp; &amp;nbsp; if (!theOriginalResultItemsFunction || !theOriginalClearResultPageFunction)&lt;/SPAN&gt;
&lt;SPAN style="font-size: 13px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;return;&lt;/SPAN&gt;

&lt;SPAN style="font-size: 13px;"&gt;&amp;nbsp; &amp;nbsp; theWidget._addResultItems = function (features, resultLayer, relatedResults, relatedTableIds) {&lt;/SPAN&gt;
&lt;SPAN style="font-size: 13px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;var self = this;&lt;/SPAN&gt;
&lt;SPAN style="font-size: 13px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;theOriginalResultItemsFunction.call(self, features, resultLayer, relatedResults, relatedTableIds);&lt;/SPAN&gt;

&lt;SPAN style="font-size: 13px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;... my bla bla&lt;/SPAN&gt;
&lt;SPAN style="font-size: 13px;"&gt;&amp;nbsp; &amp;nbsp; };&lt;/SPAN&gt;
&lt;SPAN style="font-size: 13px;"&gt;&amp;nbsp; &amp;nbsp; theWidget._clearResultPage = function () {&lt;/SPAN&gt;
&lt;SPAN style="font-size: 13px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;var self = this;&lt;/SPAN&gt;
&lt;SPAN style="font-size: 13px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;theOriginalClearResultPageFunction.call(self);&lt;/SPAN&gt;

&lt;SPAN style="font-size: 13px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;... my bla bla&lt;/SPAN&gt;
&lt;SPAN style="font-size: 13px;"&gt;&amp;nbsp; &amp;nbsp; };&lt;/SPAN&gt;
&lt;SPAN style="font-size: 13px;"&gt;&amp;nbsp; };&lt;/SPAN&gt;
&lt;SPAN style="font-size: 13px;"&gt;&amp;nbsp; if (!queryWidget) {&lt;/SPAN&gt;
&lt;SPAN style="font-size: 13px;"&gt;&amp;nbsp; &amp;nbsp; widget.widgetManager.loadWidget(widgetConfigs[0]).then(lang.hitch(widget, function (currentWidget) { connectFunction(currentWidget); }));&lt;/SPAN&gt;
&lt;SPAN style="font-size: 13px;"&gt;&amp;nbsp; }&lt;/SPAN&gt;
&lt;SPAN style="font-size: 13px;"&gt;&amp;nbsp; else {&lt;/SPAN&gt;
&lt;SPAN style="font-size: 13px;"&gt;&amp;nbsp; &amp;nbsp; connectFunction(queryWidget);&lt;/SPAN&gt;
&lt;SPAN style="font-size: 13px;"&gt;&amp;nbsp; }&lt;/SPAN&gt;
&lt;SPAN style="font-size: 13px;"&gt; }&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; Thanks Robert!&lt;/P&gt;&lt;P&gt;Alvaro&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 16:41:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/detecting-selection-event-on-query-or-attribute/m-p/607004#M56776</guid>
      <dc:creator>ahuarte</dc:creator>
      <dc:date>2021-12-12T16:41:23Z</dc:date>
    </item>
  </channel>
</rss>

