Attributes and aliases

539
1
07-07-2011 11:17 AM
AndrewBrown1
Occasional Contributor II
I recently decided to implement an alias for every field stored in my featureclass, and once I did, things stopped working. After doing some research and using the debugger, I realized that the attributes results of my identify task contained the aliases, which contained spaces, instead of the field names.

When the code snippet below is executed in my application, the datastore never reads in the data, yet the data is there. I have a feeling this is because the attribute fields contain spaces (aliases) rather than the actual field names.

I build a dynamic table to display the identified results, and I currently use the alias as the table header name and the field name as the table header value.

How do I enforce the identify results to use the field names, rather than the aliases?

I'm still new at this, so please bare with me.

Cheers,
Andrew

function showResults(results) {
var fieldName, fieldNameArr = [];
        var items = []; //all items to be stored in data store
        for (var i = 0, il = results.length; i < il; i++) {
          items.push(results.feature.attributes); //append each attribute list as item in store
          var graphic = results.feature;
          switch(results.geometryType) {
            case "esriGeometryPoint":
              symbol = new esri.symbol.SimpleMarkerSymbol();
              break;
            case "esriGeometryPolygon":
              symbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([98, 194, 204]), 2), new dojo.Color([98, 194, 204, 0.5]));
              break;
          }
          graphic.setSymbol(symbol);
          map.graphics.add(graphic);
          

        }
        
        
        for (fieldName in results[0].feature.attributes) {
          if (results[0].feature.attributes.hasOwnProperty(fieldName)) {
            fieldNameArr.push({
              field: fieldName,
              name: fieldName,
              editable: false
            });
          }
        }
//Create data object to be used in store
        var data = {
          identifier: "OBJECTID", //This field needs to have unique values
          
          items: items
        };
        
        //Create data store and bind to grid.
        store = new dojo.data.ItemFileReadStore({
          data: data
        });
}
0 Kudos
1 Reply
AndrewBrown1
Occasional Contributor II
Also, why does the esri.Graphic.attributes store the alias rather than the field name of a point's attributes that it represents?

Can I enforce the field name?
0 Kudos