Select to view content in your preferred language

How to get a particular attribute value from a FeatureSet?

4550
4
07-28-2010 08:59 AM
SreeS
by
Emerging Contributor
I would like to know if there is a way to get value of a particular attribute from a featureSet?

For Ex, when I do a queryTask the OnResult() method gets a FeatureSet.

I can get values of all attributes -> featureSet.attributes
I can get the geometry -> featureSet.features[0].geometry

But how do I access a particular attribute value from the featureSet?
Tags (2)
0 Kudos
4 Replies
RobertScheitlin__GISP
MVP Emeritus
Sree,

  
featureSet.attributes["field name"]
0 Kudos
DasaPaddock
Esri Regular Contributor
Small correction since FeatureSet.attributes is an Array

featureSet.attributes[0]["field name"]; // gets the value of a field from the first feature

This is the same as:
featureSet.features[0].attributes["field name"]
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Dasa,

  Thanks That is what I get for going off the top of my head and not checking first.
0 Kudos
SreeS
by
Emerging Contributor
Those are some pretty quick responses.

Thank you guys. Really appreciate it!!

Ive tried almost all combinations, but for the one from Dasa. And it works!!
0 Kudos