AnsweredAssumed Answered

infoTemplate - content from a function - field aliases

Question asked by schlot on Nov 18, 2014
Latest reply on Nov 18, 2014 by kenbuja

I have an infoTemplate with a function for generating the content.  I'd like to be able to use this same function again for my click event on my grid.  The problem is that I have some field aliases.  For my map click, it finds the alias fields just fine.  When I do the grid click, I'm executing a queryTask and the graphic result doesn't know about the field aliases.  I've read through another thread this is 'expected behavior', that the identifyTask uses the aliases just fine.


I have multiple layers I want to be able to click on on the map, but only one layer that's populated in a grid.  At the moment, that layer is loaded as a ArcGISDynamicMapServiceLayer.  Would it help to load this as a featureLayer instead and do a featureLayer.selectFeatures?  Do featureLayers honor aliases any better than a queryTask does?


I've created a series of arrays to use for each layer, since I want to control which fields will appear in the infoTemplate:

      var pubSchoolAtt = ['OBJECTID','Facility','Address', 'City','Phone', 'County', 'Enrollment', 'Teachers', 'BeginningGrade', 'EndingGrade'];
      var schoolDistAtt = ['OBJECTID','District Name', 'District Code'];
      var legisDistAtt = ['OBJECTID','District'];

My infoTemplate is defined as

   generateInfoTemplate = new InfoTemplate();
function generateWindowContent(graphic) {
     var attString = "";
   var layerName = graphic.attributes.layerName;//case sensitive field names
  if (!layerName){
    layerName = "School";
   var fieldNamesArr = [];
for (fieldName in graphic.attributes) {
    if (graphic.attributes.hasOwnProperty(fieldName) && fieldName !=='Shape' && fieldName !== 'Shape.area' && fieldName !== 'Shape.len') {
      case "House":
        attString = createAttRows(graphic, legisDistAtt);
      case "Senate":
      attString = createAttRows(graphic, legisDistAtt);
      case "School":
       attString = createAttRows(graphic, pubSchoolAtt);
      case "Public School":
      attString = createAttRows(graphic, pubSchoolAtt);
      case "School District":
         attString = createAttRows(graphic, schoolDistAtt);
       attString = createAttRows(graphic, fieldNamesArr, layerName);
   initTable = "<b class = 'infoHeader'>"+ layerName +" Information</b>";
   initTable = initTable + "<table id='infoWindowTable' data-dojo-type='dgrid/OnDemandGrid',' data-dojo-props='class:'infoTable'' ><tr><th></th><th></th></tr>"; 
   initTable = initTable + attString;
   initTable = initTable + "</table>";
     return initTable;

Here's my grid click event

function highlightGridSelection(event, dGrid) {
    var row = dGrid.row(event);
    var query = new Query();
    var schName = [];
    var cityName = [];
    query.where = "Facility = '" + schName + "' and " + "City = '" + cityName + "'";
    query.returnGeometry = true;
    query.outFields = ["*"];
    query.outSpatialReference = spatialReference;
    var queryTask = new QueryTask(educationLayer.url+"/0");
    queryTask.execute(query, highlightResults);
function highlightResults(results) {
    if (results) {
      var feature = results.features[0];//already esri.Graphic
 //     var featType = feature.geometry.type;
      var graphic = new Graphic(feature.geometry, highlightMarkerSymbol);
      map.infoWindow.setFeatures(results.features);; ;
    } else {
        console.log("No records by that ID");

Does anybody have any clever ideas on how I can my one function work for both type of events?