<?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: how to query with combobox with Flex in ArcGIS API for Flex Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/how-to-query-with-combobox-with-flex/m-p/230576#M5443</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Spencer and Alexander,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;There are, of course, two stages.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;OL&gt;&lt;BR /&gt;&lt;LI&gt;Populate the combobox with items from a layer during application intialization.&lt;/LI&gt;&lt;BR /&gt;&lt;LI&gt;Use the user selected item to query agains that layer&lt;/LI&gt;&lt;BR /&gt;&lt;/OL&gt;&lt;SPAN&gt;One problem with step one that I had was that the items in the layer were not unique, but I needed to provide a unique list for the user.&amp;nbsp; First I did a query to return all records in the layer.&amp;nbsp; Then I filtered that returned dataset for unique values of the field I wanted to use to populate the control.&amp;nbsp; The code below shows how I filtered the data.&amp;nbsp; I actually used a drop down list control, but the process is the same.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
private function onDDLInitComplete(fSet:FeatureSet, token:Object=null):void
&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp; //defines and sorts a unique list of values for the drop down list control
&amp;nbsp;&amp;nbsp;&amp;nbsp; //Populates the bindable application variable ddlValuesAC
&amp;nbsp;&amp;nbsp;&amp;nbsp; var i:int = 1;
&amp;nbsp;&amp;nbsp;&amp;nbsp; var item:String;
&amp;nbsp;&amp;nbsp;&amp;nbsp; var sortAttr:Array=fSet.attributes.sortOn("FieldName");
&amp;nbsp;&amp;nbsp;&amp;nbsp; for (var j:int=0; j&amp;lt;fSet.attributes.length-1; j++)
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; item = sortAttr&lt;J&gt;.FieldName;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //getItemIndex returns -1 it item is not found in the array
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; i=ddlValuesAC.getItemIndex(item);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (i==-1){
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ddlValuesAC.addItem(item);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp; }
&lt;/J&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Now that I have a drop down list with just the unique values from the layer, I can return one to many records depending on the user's selection.&amp;nbsp; Code example below.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
protected function ddlControl_changeHandler(event:IndexChangeEvent):void
&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp; mapQuery.where="fieldName = '" + ddlControl.selectedItem + "'";
&amp;nbsp;&amp;nbsp;&amp;nbsp; mapQuery.geometry = null;&amp;nbsp; //this in case geometry was used in previous query
&amp;nbsp;&amp;nbsp;&amp;nbsp; mapQueryTask.execute(mapQuery, new AsyncResponder(onQueryExecuteComplete, onFault));
&amp;nbsp;&amp;nbsp; }
&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;You will use the onQueryExecuteCompleteFunction to display the data to the user in the manner that meets your application requirements.&amp;nbsp; Likely you will use the results to populate a variable that is bound to the dataProvider attribute of a dataGrid control.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Good Luck,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;-Dan&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 11:12:39 GMT</pubDate>
    <dc:creator>DanJensen</dc:creator>
    <dc:date>2021-12-11T11:12:39Z</dc:date>
    <item>
      <title>how to query with combobox with Flex</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/how-to-query-with-combobox-with-flex/m-p/230573#M5440</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi there,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is there any sample that I can refer to make a Query using Combobox in Flex? I am very new in Flex so any help will do. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you in advance&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Sep 2010 02:34:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/how-to-query-with-combobox-with-flex/m-p/230573#M5440</guid>
      <dc:creator>SpencerTrevor</dc:creator>
      <dc:date>2010-09-29T02:34:50Z</dc:date>
    </item>
    <item>
      <title>Re: how to query with combobox with Flex</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/how-to-query-with-combobox-with-flex/m-p/230574#M5441</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am very much looking to do the same thing so I will keep a close eye on this thread too!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Sep 2010 12:37:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/how-to-query-with-combobox-with-flex/m-p/230574#M5441</guid>
      <dc:creator>Alexandervan_der_Schans</dc:creator>
      <dc:date>2010-09-29T12:37:48Z</dc:date>
    </item>
    <item>
      <title>Re: how to query with combobox with Flex</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/how-to-query-with-combobox-with-flex/m-p/230575#M5442</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Code exemple (multi combobox)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;There exist many ways to populate combobox, search in flex documentation&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;mx:ComboBox id="rue" width="90%" prompt="Sélectionner une rue ..." dataProvider="{XMLData}" labelField="name" /&amp;gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;mx:ComboBox id="civique" width="90%" prompt="Sélectionner un numéro civique ..." dataProvider="{rue.selectedItem.civique}"/&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;mx:HBox horizontalAlign="center" width="100%"&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &amp;lt;mx:Button label="{submitLabel}" click="queryFeaturesText(4)"/&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &amp;lt;mx:Button label="{clearLabel}" click="clear()"/&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;/mx:HBox&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;i hope this help&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Sep 2010 14:56:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/how-to-query-with-combobox-with-flex/m-p/230575#M5442</guid>
      <dc:creator>erictruchon</dc:creator>
      <dc:date>2010-09-29T14:56:51Z</dc:date>
    </item>
    <item>
      <title>Re: how to query with combobox with Flex</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/how-to-query-with-combobox-with-flex/m-p/230576#M5443</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Spencer and Alexander,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;There are, of course, two stages.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;OL&gt;&lt;BR /&gt;&lt;LI&gt;Populate the combobox with items from a layer during application intialization.&lt;/LI&gt;&lt;BR /&gt;&lt;LI&gt;Use the user selected item to query agains that layer&lt;/LI&gt;&lt;BR /&gt;&lt;/OL&gt;&lt;SPAN&gt;One problem with step one that I had was that the items in the layer were not unique, but I needed to provide a unique list for the user.&amp;nbsp; First I did a query to return all records in the layer.&amp;nbsp; Then I filtered that returned dataset for unique values of the field I wanted to use to populate the control.&amp;nbsp; The code below shows how I filtered the data.&amp;nbsp; I actually used a drop down list control, but the process is the same.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
private function onDDLInitComplete(fSet:FeatureSet, token:Object=null):void
&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp; //defines and sorts a unique list of values for the drop down list control
&amp;nbsp;&amp;nbsp;&amp;nbsp; //Populates the bindable application variable ddlValuesAC
&amp;nbsp;&amp;nbsp;&amp;nbsp; var i:int = 1;
&amp;nbsp;&amp;nbsp;&amp;nbsp; var item:String;
&amp;nbsp;&amp;nbsp;&amp;nbsp; var sortAttr:Array=fSet.attributes.sortOn("FieldName");
&amp;nbsp;&amp;nbsp;&amp;nbsp; for (var j:int=0; j&amp;lt;fSet.attributes.length-1; j++)
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; item = sortAttr&lt;J&gt;.FieldName;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //getItemIndex returns -1 it item is not found in the array
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; i=ddlValuesAC.getItemIndex(item);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (i==-1){
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ddlValuesAC.addItem(item);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp; }
&lt;/J&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Now that I have a drop down list with just the unique values from the layer, I can return one to many records depending on the user's selection.&amp;nbsp; Code example below.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
protected function ddlControl_changeHandler(event:IndexChangeEvent):void
&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp; mapQuery.where="fieldName = '" + ddlControl.selectedItem + "'";
&amp;nbsp;&amp;nbsp;&amp;nbsp; mapQuery.geometry = null;&amp;nbsp; //this in case geometry was used in previous query
&amp;nbsp;&amp;nbsp;&amp;nbsp; mapQueryTask.execute(mapQuery, new AsyncResponder(onQueryExecuteComplete, onFault));
&amp;nbsp;&amp;nbsp; }
&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;You will use the onQueryExecuteCompleteFunction to display the data to the user in the manner that meets your application requirements.&amp;nbsp; Likely you will use the results to populate a variable that is bound to the dataProvider attribute of a dataGrid control.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Good Luck,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;-Dan&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 11:12:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/how-to-query-with-combobox-with-flex/m-p/230576#M5443</guid>
      <dc:creator>DanJensen</dc:creator>
      <dc:date>2021-12-11T11:12:39Z</dc:date>
    </item>
  </channel>
</rss>

