Select to view content in your preferred language

FeatureLayer SelectFeatures Function Arguments

2638
4
06-09-2011 06:22 AM
DeonaEvans
Emerging Contributor
I'm trying to use the FeatureLayer.selectFeatures function but I can't seem to find an example that shows me the arguments to the handler function for this.

_featureLayer.selectFeatures(q, FeatureLayer.SELECTION_ADD, new AsyncResponder(selectFeaturesHandler, selectFeaturesFault));

What are the function parameters for selectFeaturesHandler?  Where do I find this documented?
Tags (2)
0 Kudos
4 Replies
ReneRubalcava
Esri Frequent Contributor
When you add a Responder the FeatureLayer.selectFeatures, you're going to get back an array of the graphics that have been added to your selection.

So you can write out your handler as
private function selectFeaturesHandler(features:Array):void
{
    // do what you need to do with the graphics
}


selectFeatures will fire the selectionComplete event
http://help.arcgis.com/en/webapi/flex/apiref/com/esri/ags/layers/FeatureLayer.html#event:selectionCo...

The Responder will refer to the FeatureLayerEvent
http://help.arcgis.com/en/webapi/flex/apiref/com/esri/ags/events/FeatureLayerEvent.html

Which when responding to selectFeatures will return the features array
http://help.arcgis.com/en/webapi/flex/apiref/com/esri/ags/events/FeatureLayerEvent.html#features

When reading the docs, sometimes you just need to follow the breadcrumbs 🙂
0 Kudos
IvanBespalov
Frequent Contributor
Related Records sample in Samples -> FeatureLayer -> RelatedRecords

Multiple Related Records sample in Samples -> FeatureLayer -> Multiple Related Records
0 Kudos
by Anonymous User
Not applicable
Greetings All!

When I run the code:

    _featureLayer.selectFeatures(q, FeatureLayer.SELECTION_ADD, new AsyncResponder(selectFeaturesHandler, selectFeaturesFault));

in my widget code, I get an error thrown in AsyncResponder.as that says "Argument count mismatch ... Expected 1, got 2..."

I'm able to get around this by adding a bogus temporary FeatureLayer to my widget code directly with the selectionComplete function pre-specified in the declaration and then running my selectFeatures against that, but when I do that I run into problems when trying to display the graphical output of the operation on my map.

I guess what I'm looking for is some sample code of using the selectFeatures on a Feature Layer defined in the main config.xml file that displays the selected features on the map and behaves as expected. If anyone can point me to some code I'd be extremely grateful! Thanks in advance ...

- Bob
0 Kudos
DasaPaddock
Esri Regular Contributor
0 Kudos