<?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: Sorting FilteringSelect in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/sorting-filteringselect/m-p/434870#M40040</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks Steve,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;It worked for me as well. The next thing I need to do is to sort the html list that is displayed after user selects state(s).&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Samir&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 16 Apr 2013 15:45:54 GMT</pubDate>
    <dc:creator>SamirGambhir</dc:creator>
    <dc:date>2013-04-16T15:45:54Z</dc:date>
    <item>
      <title>Sorting FilteringSelect</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/sorting-filteringselect/m-p/434868#M40038</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I have a data store with names of states queried from a feature layer as shown in &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://help.arcgis.com/en/webapi/javascript/arcgis/jssamples/fl_zoomgrid.html" rel="nofollow" target="_blank"&gt;this&lt;/A&gt;&lt;SPAN&gt; example. Here is my code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;//Populate the ComboBox with unique values&amp;nbsp; var stateName;&amp;nbsp; var values = [];&amp;nbsp; var testVals = {};&amp;nbsp;&amp;nbsp; //Add option to display all district names to the ComboBox&amp;nbsp; values.push({ &amp;nbsp; name : "All India"&amp;nbsp; });&amp;nbsp;&amp;nbsp; //Loop through the QueryTask results and populate an array&amp;nbsp; //with the unique values&amp;nbsp; var features = results.features;&amp;nbsp; dojo.forEach(features, function(feature) { &amp;nbsp; stateName = feature.attributes.State_name; &amp;nbsp; if (!testVals[stateName]) { &amp;nbsp;&amp;nbsp; testVals[stateName] = true; &amp;nbsp;&amp;nbsp; values.push({ &amp;nbsp;&amp;nbsp;&amp;nbsp; name : stateName &amp;nbsp;&amp;nbsp; }); &amp;nbsp; }&amp;nbsp; });&amp;nbsp; //Create a ItemFileReadStore and use it for the&amp;nbsp; //ComboBox's data source&amp;nbsp; var dataItems = { &amp;nbsp; identifier : 'name', &amp;nbsp; label : 'name', &amp;nbsp; items : values&amp;nbsp; };&amp;nbsp;&amp;nbsp; var storeS = new dojo.data.ItemFileReadStore({ &amp;nbsp; data : dataItems&amp;nbsp; });&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This data store is attached to a filteringSelect:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;dijit.byId("selStateM2").set("store", storeS);&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;SPAN&gt;Before ataching the store to my filteringSelect, I would like to sort the state names in alphabetical order. Here is my code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;var sortAttr = [{ &amp;nbsp; attribute : "name", &amp;nbsp; ascending : true&amp;nbsp; }];&amp;nbsp; storeS.fetch({ &amp;nbsp; query : {}, &amp;nbsp; sort : sortAttr });&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;SPAN&gt;I need help in understanding how to push this sorted list to my filteringSelect.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Samir&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Apr 2013 14:00:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/sorting-filteringselect/m-p/434868#M40038</guid>
      <dc:creator>SamirGambhir</dc:creator>
      <dc:date>2013-04-16T14:00:52Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting FilteringSelect</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/sorting-filteringselect/m-p/434869#M40039</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I specify the sorting over on the HTML side of things for filteringSelect by adding the following:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;searchAttr="&amp;lt;your field name&amp;gt;" fetchProperties="{sort:[{attribute:'&amp;lt;your field name&amp;gt;', descending:false}]}"&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The full HTML reference looks like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;&amp;lt;input id="cboCrossStEnd" dojoType="dijit.form.FilteringSelect" checked="checked" searchAttr="CROSSST" name="WidgetName" pageSize="6" fetchProperties="{sort:[{attribute:'CROSSST', descending:false}]}" placeHolder="Select a road from the list" onChange="&amp;lt;your function here&amp;gt;" /&amp;gt;&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here's my JS code for populating the filteringSelect (this is triggered via dojo.connect during the onLoad event):&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;function populateRdNameCbo(results) {&amp;nbsp; //Populate the dropdown list box with unique values&amp;nbsp; values = []; &amp;nbsp;&amp;nbsp;&amp;nbsp; testVals = {};&amp;nbsp;&amp;nbsp;&amp;nbsp; features = results.features;&amp;nbsp; dojo.forEach (features, function(feature) { &amp;nbsp; curName = feature.attributes.FULLNAME; &amp;nbsp; if (!testVals[curName]) { &amp;nbsp;&amp;nbsp; testVals[curName] = true; &amp;nbsp;&amp;nbsp; values.push({"OBJECTID":feature.attributes.OBJECTID,"RDNAME":feature.attributes.FULLNAME}); &amp;nbsp; }&amp;nbsp; });&amp;nbsp;&amp;nbsp;&amp;nbsp; dataItems = { &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; identifier: "OBJECTID", &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; label: "RDNAME", &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; items: values&amp;nbsp; };&amp;nbsp;&amp;nbsp;&amp;nbsp; theStore = new dojo.data.ItemFileReadStore({data:dataItems});&amp;nbsp;&amp;nbsp; dijit.byId("cboRdName").set("store", theStore);&amp;nbsp; }&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My code also eliminates duplicate entries as it adds items to the list. Seems to work for me.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Apr 2013 14:13:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/sorting-filteringselect/m-p/434869#M40039</guid>
      <dc:creator>SteveCole</dc:creator>
      <dc:date>2013-04-16T14:13:18Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting FilteringSelect</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/sorting-filteringselect/m-p/434870#M40040</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks Steve,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;It worked for me as well. The next thing I need to do is to sort the html list that is displayed after user selects state(s).&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Samir&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Apr 2013 15:45:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/sorting-filteringselect/m-p/434870#M40040</guid>
      <dc:creator>SamirGambhir</dc:creator>
      <dc:date>2013-04-16T15:45:54Z</dc:date>
    </item>
  </channel>
</rss>

