Select to view content in your preferred language

Remove selections from a FeatureLayer

2081
2
09-09-2010 07:51 AM
ReneRubalcava
Esri Frequent Contributor
I was curious if there was a clean way to remove particular selections from a Featurelayer.
I tried a couple of different methods to limit the selection to first selected feature.

I thought I could cheat and splice the selectedFeatures
var x:uint = featurelayer.selectedFeatures.length;
featurelayerselectedFeatures.splice(1,x);

But that didn't work.

Then I tried to grab the first graphic and make a new FeatureCollection
var g:Graphic = featurelayer.selectedFeatures[0];
featureLayer.featureCollection = new FeatureCollection(new FeatureSet());

That didn't work either.

The next step I suppose would be to use the first graphic geometry to do second selection query on the FeatureLayer, but that seems a bit heavy handed.

The reason I am using FeatureLayer is that this is for a custom component and it is much simpler to pass a FeatureLayer with built in query/selection capabilities than to pass a QueryTask URL and an existing GraphicsLayer on the Map, plus it fits into my workflow as I have some listeners in the main app for when a selection ends on the FeatureLayer being passed.

If there's no way to tweak the SelectedFeatures after the fact, I'll just go the QueryTask/GraphicsLayer route, but I figure it couldn't hurt to ask.
Tags (2)
0 Kudos
2 Replies
DasaPaddock
Esri Regular Contributor
You can call selectFeatures() where the selectionMethod is SELECTION_SUBTRACT.
Reference:
http://help.arcgis.com/en/webapi/flex/apiref/com/esri/ags/layers/FeatureLayer.html#selectFeatures()
0 Kudos
ReneRubalcava
Esri Frequent Contributor
Aha, that did the trick!
Thanks Dasa.
0 Kudos