AnsweredAssumed Answered

Sorting FilteringSelect

Question asked by samirgambhir on Apr 16, 2013
Latest reply on Apr 16, 2013 by samirgambhir
Hello,
I have a data store with names of states queried from a feature layer as shown in this example. Here is my code:
//Populate the ComboBox with unique values  var stateName;  var values = [];  var testVals = {};   //Add option to display all district names to the ComboBox  values.push({   name : "All India"  });   //Loop through the QueryTask results and populate an array  //with the unique values  var features = results.features;  dojo.forEach(features, function(feature) {   stateName = feature.attributes.State_name;   if (!testVals[stateName]) {    testVals[stateName] = true;    values.push({     name : stateName    });   }  });  //Create a ItemFileReadStore and use it for the  //ComboBox's data source  var dataItems = {   identifier : 'name',   label : 'name',   items : values  };   var storeS = new dojo.data.ItemFileReadStore({   data : dataItems  });


This data store is attached to a filteringSelect:
dijit.byId("selStateM2").set("store", storeS);

Before ataching the store to my filteringSelect, I would like to sort the state names in alphabetical order. Here is my code:
var sortAttr = [{   attribute : "name",   ascending : true  }];  storeS.fetch({   query : {},   sort : sortAttr });

I need help in understanding how to push this sorted list to my filteringSelect.
Thanks
Samir

Outcomes