how to filter data in a FeatureLayer

5884
1
05-08-2012 08:16 AM
raphael_hernandesguimenes
New Contributor
Hi all!!

I'm a new user of ArcGIS and i i doubt a simple.

I have a layer on my server ARCGIS. This layer looks for information that is in a database

I would like to filter the data of layer via javascript.

Example:

[INDENT]Layer: Customers
Table of database: TCustomers
Layer in the javascript:
var featureLayerUrl = "http://vminter:8399/arcgis/rest/services/Layer/MapServer/0";
featureLayer = new esri.layers.FeatureLayer(featureLayerUrl, {
          maxAllowableOffset: maxOffset(map,1)
        });
[/INDENT]

I want the layer show only customers with a name like jony. Anyone know how to do this via javascript?
0 Kudos
1 Reply
PaulBushore
Occasional Contributor
Hello, if I understand you correctly, you should be able to use the method for feature layers:

featureLayer.setDefinitionExpression("STATE_NAME = 'South Carolina'");

Hope that gets you started, you can learn more from the API Reference:

http://help.arcgis.com/en/webapi/javascript/arcgis/help/jsapi_start.htm


Best wishes!


Hrmm the more I think about this, the more I think that he is looking to set the definition query based on a joined/related record rather than the base layer information.  I am not certain if the definition query based on a join/related record is supported, may be, but not certain.
0 Kudos