AnsweredAssumed Answered

Getting selected features

Question asked by samirgambhir on May 28, 2013
Latest reply on May 31, 2013 by samirgambhir
A small part of my application is to select one or more features and display those for a selected indicator. This function is working fine. I now need to expand this functionality to populate a grid with attributes of these selected features. The issue I am facing is that even if I change my indicator, the function does not reset the selection. The attributes returned are from the original indicator selection. Here is the relevant code:
function queryParam(event) {   var resultContent, symbols, newGeog = [], strNewGeog;   queryTask = new esri.tasks.QueryTask(myURL);   query = new esri.tasks.Query();   query.returnGeometry = true;   query.outFields = ["*"];   query.where = "1=1";   resultContent = "<tr>" + event.indc + ": <td>${" + event.indv + ":formatNumber}</td></tr>";//Indicator name and values are passed as parameters from another event   ...   /* set of parameters supplied for generating a renderer*/   ...   var gR = new esri.tasks.GenerateRendererTask(myURL);   gR.execute(params, function(renderer) {     ...     distFeatureLayer.setDefinitionExpression(strNewGeog);//strNewGeog is some expression of selecting geographies     distFeatureLayer.selectFeatures(query, esri.layers.FeatureLayer.SELECTION_NEW);     dojo.connect(distFeatureLayer, "onSelectionComplete", function(features) {       /*This is where the problem starts*/       dojo.forEach(features, function(feature) {         var gridDistName = feature.attributes.Dist_name + " - " + feature.attributes.St_abbr;  alert("check "+event.indv);  var gridIndValue = feature.attributes[event.indv];//THIS event.indv IS STUCK WITH THE ORIGINAL SELECTION AND DOES NOT CHANGE. Console.log RIGHT BEFORE dojo.connect RETURNS THE NEW SELECTED INDICATOR  items.push(gridDistName, gridIndValue);       });       data = {         identifier : "gridDistName",  items : items       };       var gridStore = new{  data : data       });       dijit.byId("grid").set("store", gridStore);     });     distFeatureLayer.setRenderer(renderer);   });//End of gR.execute } //End of function