abrown31

Attributes and aliases

Discussion created by abrown31 on Jul 7, 2011
Latest reply on Jul 7, 2011 by abrown31
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[i].feature.attributes); //append each attribute list as item in store
          var graphic = results[i].feature;
          switch(results[i].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
        });
}

Outcomes