Sowjanya

How to add features using SELECTION_ADD ?

Discussion created by Sowjanya on Nov 29, 2011
Latest reply on May 3, 2013 by mkoneya
I'm working on the following scenario and need help with selection_ADD and selection_SUBTRACT.

1. User selects a bunch of features (a New selection) on the map using a selection tool:
fLayer = new esri.layers.FeatureLayer(selUrl, {
            mode: esri.layers.FeatureLayer.MODE_SELECTION,
            outFields: ["*"]
        });
        map.addLayer(fLayer);
var selSymbol = new esri.symbol.SimpleFillSymbol().setColor(new dojo.Color([255, 255, 0, 0.5]));
fLayer.setSelectionSymbol(selSymbol);
    var selResults = "";

    selectQuery = new esri.tasks.Query();
    selectQuery.geometry = geometry;

fLayer.selectFeatures(selectQuery, esri.layers.FeatureLayer.SELECTION_NEW, function (features) {


            alert("NEW " + features.length);

        });
2. Then the user selects a second bunch of features ( add to selection) and these features have to be added to the already existing selection set.
fLayer.selectFeatures(selectQuery, esri.layers.FeatureLayer.SELECTION_ADD, function (features) {

            for (var x = 0; x < features.length; x++) {
                selResults = selResults + ";" + features[x].attributes['X_REF'];
            }

            alert("APN:" + selResults);


        });

When I do this, the map shows all selected features (graphics) but I'm unable to get ALL the feature attributes. Only the last (recent) selected attributes are returned.

Any ideas how to make the Feature layer retuen all the Feaures?

Outcomes