Select to view content in your preferred language

Populate combo box in widget from Map Service Table (ArcGIS Server 10)

2842
4
10-20-2010 09:26 AM
BarbaraPatterson
Emerging Contributor
I'm creating a new widget with a series of combo boxes. The data source for each como box is a table that is part of a map service. Is it necessary to loop through the table and add the values to the combobox? Or can I just somehow reference the table using the QueryTask. Below is a snippet of my code showing what I'm trying to do. Any help or samples would be greatly appreciated!

Thanks, Barb Patteron

<fx: Declarations>
  <esri:QueryTask id="queryApps"
      url="http://arcportal-gamma/ArcGIS/rest/services/MyMapService/MapServer/1"
      useAMF="false"/>
  <esri:Query id="query"
     outFields="[AppScenario]"
     returnGeometry="false"
     />
</fx: Declarations>

Inside my widget template I have:
<mx:VBox>
     <mx:Label text="App Scenario"/>
     <mx:ComboBox id="App" labelField="" dataProvider="{queryApps.execute(query)}"/>
    </mx:VBox>
Tags (2)
0 Kudos
4 Replies
Drew
by
Frequent Contributor
I don�??t believe that�??s possible. You need a �??complete�?� event handler.

You could have a helper function that would fill the combo box..

Sample (works)


 private function fillComboBoxWithData(cmb:ComboBox, displayFieldName:String, featureSet:FeatureSet):void
 {
  var results:ArrayCollection = new ArrayCollection();
  for each (var graphic:Graphic in featureSet.features)
  {
   var fieldValue:String = graphic.attributes[displayFieldName].toString(); 
   results.addItem({label: fieldValue, data:graphic});
  }
  cmb.labelField = "label";
  cmb.dataProvider = results;
 }



Drew
0 Kudos
DanJensen
Deactivated User
Barbara,

I think you will need to execute the query through a helper function, then it may be possible to bind the dataProvider property of the comboBox to the executeLastResult property of the query task.
0 Kudos
NadeemShaukat
Deactivated User
I'm creating a new widget with a series of combo boxes. The data source for each como box is a table that is part of a map service. Is it necessary to loop through the table and add the values to the combobox? Or can I just somehow reference the table using the QueryTask. Below is a snippet of my code showing what I'm trying to do. Any help or samples would be greatly appreciated!

Thanks, Barb Patteron

<fx: Declarations>
  <esri:QueryTask id="queryApps"
      url="http://arcportal-gamma/ArcGIS/rest/services/MyMapService/MapServer/1"
      useAMF="false"/>
  <esri:Query id="query"
     outFields="[AppScenario]"
     returnGeometry="false"
     />
</fx: Declarations>

Inside my widget template I have:
<mx:VBox>
     <mx:Label text="App Scenario"/>
     <mx:ComboBox id="App" labelField="" dataProvider="{queryApps.execute(query)}"/>
    </mx:VBox>


Barbara,

I see you were looking for a solution to populate a combobox with values from a table present in a map service. I am also trying to do the same thing to populate with values in a field of a feature class in a service. I also need to create this list of unique values.

Have you figured out how to do it. If so, please post a sample.

nshaukat
0 Kudos
DanJensen
Deactivated User
nshaukat,

Take a look at this thread for populating a combo box from a feature class field and ensuring they are unique and sorted.

http://forums.arcgis.com/threads/13929-how-to-query-with-combobox-with-Flex
0 Kudos