<?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: Filtering a FeatureLayerView in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/filtering-a-featurelayerview/m-p/1016588#M71376</link>
    <description>&lt;P&gt;Hi there,&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can use &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#orderByFields" target="_self"&gt;Query.orderByFields&lt;/A&gt;&amp;nbsp;property to order your query results. Then pass the specified query object to &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-FeatureLayerView.html#queryFeatures" target="_self"&gt;FeatureLayerView.queryFeatures()&lt;/A&gt; method. You can choose to display the returned features on the map by adding them to graphics layer. You can also display the attributes where you need.&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can also take advantage of &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-FeatureLayerView.html#filter" target="_self"&gt;FeatureLayerView.filter&lt;/A&gt;&amp;nbsp;to display only features that meet your filter criteria. Then you can use the same criteria to query the features.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In &lt;A href="https://codepen.io/U_B_U/pen/abmQvJz?editors=1000" target="_self"&gt;this simple app&lt;/A&gt;, I am using FeatureLayerView.filter to only display counties of the selected state. Then I use the filter criteria to query the counties of that state. In the query, I set the query.orderByFields to county names. When the results are returned, they are ordered by the county names.&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the code snippet that is most beneficial to you probably:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;countiesLayerView.filter = {
  geometry: result.geometry // state geometry
};

var query = countiesLayerView.filter.createQuery();
query.orderByFields = ["COUNTY"];
countiesLayerView.queryFeatures(query).then(function(results){
  results.features.forEach(function(feature){
    console.log(feature.attributes.county);
  });
});&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;Check out &lt;A href="https://codepen.io/U_B_U/pen/abmQvJz?editors=1000" target="_self"&gt;this simple app&lt;/A&gt;.&amp;nbsp; The following screenshot shows how to use the app. Hopefully it is descriptive enough.&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="testapp.gif" style="width: 480px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/3794iA57DEC398C106BB9/image-size/large?v=v2&amp;amp;px=999" role="button" title="testapp.gif" alt="testapp.gif" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 13 Jan 2021 21:03:30 GMT</pubDate>
    <dc:creator>UndralBatsukh</dc:creator>
    <dc:date>2021-01-13T21:03:30Z</dc:date>
    <item>
      <title>Filtering a FeatureLayerView</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/filtering-a-featurelayerview/m-p/1015802#M71365</link>
      <description>&lt;P&gt;I am new to the javascript api.&amp;nbsp; I am stuck converting some arcade code into javascript.&amp;nbsp;&lt;BR /&gt;So I can add html (bold, url, etc) to the print out.&lt;/P&gt;&lt;P&gt;Basically when the user clicks it will give me an APN which I want to filter/order in the&amp;nbsp;DSD_HistoricPTS feature set&lt;/P&gt;&lt;P&gt;I believe I want to use a FeatureLayerView so the processing can take place on the clients side.&lt;/P&gt;&lt;P&gt;//arcade code below&lt;BR /&gt;var clickedParcelAPN = $feature.APN&amp;nbsp; //{APN}&amp;nbsp;&lt;/P&gt;&lt;P&gt;var filterbyAPN = 'job_apn = @clickedParcelAPN'&lt;BR /&gt;var PTSFilterAPN = Filter(DSD_HistoricPTS, filterbyAPN)&lt;BR /&gt;var PTSOrderBY_ProjectId = OrderBy(PTSFilterAPN, 'project_id')&lt;/P&gt;&lt;P&gt;for (var f1 in PTSOrderBY_ProjectId){&lt;/P&gt;&lt;P&gt;popupString += Text("Project Title: " + f1.project_title) + TextFormatting.NewLine +&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;("Project Number: " + f1.project_id) + TextFormatting.NewLine +&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;("Project Created: " + f1.date_project_create) + TextFormatting.NewLine +&lt;BR /&gt;etc&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;I can't figure out the javascript equivalent to Filter and OrderBy. I am sure there is a super simple solution but it has me stuck.&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jan 2021 23:56:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/filtering-a-featurelayerview/m-p/1015802#M71365</guid>
      <dc:creator>RyanBohan</dc:creator>
      <dc:date>2021-01-11T23:56:29Z</dc:date>
    </item>
    <item>
      <title>Re: Filtering a FeatureLayerView</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/filtering-a-featurelayerview/m-p/1016588#M71376</link>
      <description>&lt;P&gt;Hi there,&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can use &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#orderByFields" target="_self"&gt;Query.orderByFields&lt;/A&gt;&amp;nbsp;property to order your query results. Then pass the specified query object to &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-FeatureLayerView.html#queryFeatures" target="_self"&gt;FeatureLayerView.queryFeatures()&lt;/A&gt; method. You can choose to display the returned features on the map by adding them to graphics layer. You can also display the attributes where you need.&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can also take advantage of &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-FeatureLayerView.html#filter" target="_self"&gt;FeatureLayerView.filter&lt;/A&gt;&amp;nbsp;to display only features that meet your filter criteria. Then you can use the same criteria to query the features.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In &lt;A href="https://codepen.io/U_B_U/pen/abmQvJz?editors=1000" target="_self"&gt;this simple app&lt;/A&gt;, I am using FeatureLayerView.filter to only display counties of the selected state. Then I use the filter criteria to query the counties of that state. In the query, I set the query.orderByFields to county names. When the results are returned, they are ordered by the county names.&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the code snippet that is most beneficial to you probably:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;countiesLayerView.filter = {
  geometry: result.geometry // state geometry
};

var query = countiesLayerView.filter.createQuery();
query.orderByFields = ["COUNTY"];
countiesLayerView.queryFeatures(query).then(function(results){
  results.features.forEach(function(feature){
    console.log(feature.attributes.county);
  });
});&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;Check out &lt;A href="https://codepen.io/U_B_U/pen/abmQvJz?editors=1000" target="_self"&gt;this simple app&lt;/A&gt;.&amp;nbsp; The following screenshot shows how to use the app. Hopefully it is descriptive enough.&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="testapp.gif" style="width: 480px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/3794iA57DEC398C106BB9/image-size/large?v=v2&amp;amp;px=999" role="button" title="testapp.gif" alt="testapp.gif" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jan 2021 21:03:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/filtering-a-featurelayerview/m-p/1016588#M71376</guid>
      <dc:creator>UndralBatsukh</dc:creator>
      <dc:date>2021-01-13T21:03:30Z</dc:date>
    </item>
  </channel>
</rss>

