Select to view content in your preferred language

Field Alias with FeatureLayer.getSelectedFeatures();

1055
3
Jump to solution
07-19-2013 08:27 AM
MeleKoneya
Frequent Contributor
I am using the selectFeatures method on a Feature Layer to select features.   Upon completing the selection,  I am calling the .getSelectedFeatures method which returns the features and their attributes selectecd from a FeatureLayer.    I would like to get the Alias and value, rather than the field name and value to display in a form.

How can I get the Field Alias and Field Value after executing the getSelectedFeatures method?

Thanks,

Mele
0 Kudos
1 Solution

Accepted Solutions
BenFousek
Deactivated User
Here's a function from my base that takes the attributes of a feature and the feature layer itself as arguments, and returns a simple table. Also shows how to test a value against a URL regular expression.
featureAttributeTable: function(atts, feature) {   var table = '<table cellspacing="0" cellpadding="2" style="width:100%;">';   for (var i in atts) {     var alias;     dojo.forEach(feature.fields, function (field) {       if (field.name === i) {         alias = field.alias;       }     });     var value = atts;     var exp = new RegExp(/(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/);     if (exp.test(value)) {       value = '<a href="' + atts + '" title="' + atts + '" target="_blank">Hyperlink</a>'     }     table += '<tr><td><b>' + alias + '</b></td><td>' + value + '</td></tr>';   }   table += '</table>';   return table }

View solution in original post

0 Kudos
3 Replies
BenFousek
Deactivated User
The field infos, including alias can be found in the FEATURE_LAYER.fields object.
0 Kudos
MeleKoneya
Frequent Contributor
Thanks Ben,   I did find the FEATURE_LAYER.fields object and its Aliases.
     
What I would like to do is use that to substitute the field name results of getSelectedFeatures, with the Alias programmatically.

Please let me know if anyone has a code sample.

Thanks,

Mele
0 Kudos
BenFousek
Deactivated User
Here's a function from my base that takes the attributes of a feature and the feature layer itself as arguments, and returns a simple table. Also shows how to test a value against a URL regular expression.
featureAttributeTable: function(atts, feature) {   var table = '<table cellspacing="0" cellpadding="2" style="width:100%;">';   for (var i in atts) {     var alias;     dojo.forEach(feature.fields, function (field) {       if (field.name === i) {         alias = field.alias;       }     });     var value = atts;     var exp = new RegExp(/(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/);     if (exp.test(value)) {       value = '<a href="' + atts + '" title="' + atts + '" target="_blank">Hyperlink</a>'     }     table += '<tr><td><b>' + alias + '</b></td><td>' + value + '</td></tr>';   }   table += '</table>';   return table }
0 Kudos