samirgambhir

Loading grid with features from a feature layer

Discussion created by samirgambhir on Apr 20, 2012
Latest reply on Apr 20, 2012 by samirgambhir
Hi all,
I am trying to load a data grid with attributes of the selected features from a feature layer. The relevant code is below but it is not populating the grid at all. Thanks for your help in advance:
....
function viewIndicator(State) {
.....
if (unitStActiveM==true){
          stateFeatureLayer.selectFeatures(query, esri.layers.FeatureLayer.SELECTION_NEW);
          mapM.removeLayer(distFeatureLayer);
          dojo.connect(stateFeatureLayer, "onSelectionComplete", loadGrid);
          mapM.addLayers(stateFeatureLayer)
          showLegend();
          mapM.addLayers([stateFeatureLayer]);
        }
.....
}

function loadGrid(featureSet){
var items = [];
                dojo.forEach(featureSet.features, function (feature) {items.push(feature.attributes);});
       if (unitStActiveM==true){
            var data = {identifier:"OBJECT_ID", items:items};
          }
          else if (unitDistActiveM==true){
            var data = {identifier:"Object_ID", items:items};
          }
          store = new dojo.data.ItemFileWriteStore({data:data});
          returnRadioID();
          switch (selRadio)
          {
            case "checkCBR":
              store.fetch({query:{},onItem:function(item){
                var value=store.getValues(item, "CBR_01");
                store.setValues(item, "indValue", value);
                }   
              });
              break;
            case "checkTest1":
              store.fetch({query:{},onItem:function(item){
                  var value=store.getValues(item, "MMR_01");
                  store.setValues(item, "indValue", value);
                  }   
                });
              break;
          }
          dojo.style("mappingGrid", {"height":"380px"});
         
          grid = dojox.byId('mappingGrid');
          grid.setStore(store);
       }

Outcomes