Select to view content in your preferred language

Feature Layers do not have all attributes

813
5
10-12-2010 07:12 AM
BryanLin
Emerging Contributor
can anyone answer why a feature layer's graphics providers' attributes does not contain all of the layer's attributes unless it's queried?

var features:ArrayCollection = ArrayCollection(featureLayer.graphicProvider);
var featureSet:FeatureSet = new FeatureSet(features.source);

featureSet.attributes would only have fields : ObjectID, Shape, and STFIPS. I want to be able to grab all of the attributes from the feature layer, but it seems the only way is to query the feature layer. is there another way because it seems that querying for each feature would take a performance hit.
Tags (2)
0 Kudos
5 Replies
DasaPaddock
Esri Regular Contributor
0 Kudos
BryanLin
Emerging Contributor
Have you set the outFields?
http://help.arcgis.com/en/webapi/flex/apiref/com/esri/ags/layers/FeatureLayer.html#outFields


Yes i had that too. It still returns only objectid, shape,and stfips.
0 Kudos
DasaPaddock
Esri Regular Contributor
Can you post a test case? It sounds like your code is correct, but you may want to contact ESRI Tech Support to see if there's a bug here.
0 Kudos
BryanLin
Emerging Contributor
Can you post a test case? It sounds like your code is correct, but you may want to contact ESRI Tech Support to see if there's a bug here.


var featureLayer:FeatureLayer = new FeatureLayer("http://myserver/arcgis/rest/services/Example/MapServer")
var features:ArrayCollection = ArrayCollection(featureLayer.graphicProvider);
var featureSet:FeatureSet = new FeatureSet(features.source)

//find the attributes of the feature set
for each(var attribute:Object in featureSet.attributes)
{
   trace("attribute : " + attribute");
}

i believe you can also get the attribute names with:
for (var attributeName:Object in featureSet.attributes)
{
   trace("attribute name: " + attributeName + " : " + featureSet.attributes[attributeName]);
}
0 Kudos
DasaPaddock
Esri Regular Contributor
The FeatureLayer url should be to a layer in the map service. e.g.,
http://myserver/arcgis/rest/services/Example/MapServer/0

Also, FeatureSet.attributes is an Array of Objects, so you need an inner loop to pull out the values of the attributes for each feature in the FeatureSet.
http://help.arcgis.com/en/webapi/flex/apiref/com/esri/ags/FeatureSet.html#attributes
0 Kudos