evtguy

trouble populating a combo box with feature values

Discussion created by evtguy on Sep 24, 2012
Latest reply on Sep 24, 2012 by evtguy
In a web map I'm developing, I want a combo box populated with project names and FID so that once the user selects a project, I can zoom to that project's feature extent. Within my Init() function, I'm using a query task like this:

 //Push the attributes of the TIP Projects into the combo box
 var query = new esri.tasks.Query();    
 query.where = "1=1";
 query.outFields = ["*"];
 
 var queryTask = new esri.tasks.QueryTask("my feature layer URL");
        queryTask.execute(query,populateCbo);


Later down the line, my function "populateCbo" attempts to populate the combo box:

function populateCbo(results) {
 //Populate the dropdown list box with unique values
 var values = [];

 var features = results.features;
 dojo.forEach (features, function(feature) {
  curProject = feature.attributes.PROJECT;
  curFid = feature.attributes.FID;

  values.push({'project':curProject,'fid':curFid});
 });
 
 //Sort the values list by project name
 //values.sort(by('project'));
 
 var dataItems = {
     identifier: 'fid',
     label: 'project',
     items: values
 };
 var store = new dojo.data.ItemFileReadStore({data:dataItems});
 dijit.byId("cboTipList").store = store;
}


Everything seems to work just fine until the line which populates the store variable. The dataItems variable has information in it but after stepping through the "store = .." line, the data property for store is still null.

Am I not formatting the contents of dataItems properly? I'm not sure why it's not getting populated.

Thanks!
Steve

Outcomes