Arkitech

Table build in for loop from querytask

Discussion created by Arkitech on Nov 26, 2013
Latest reply on Dec 5, 2013 by zj_zou
Hi

  function showResults(results) {
          var s = "<table>";
          var aliases = results.fieldAliases;
          var len = results.features.length;
            if (len === 0) { // if no results
             s = "No results for reference: " + TESTREF
            } else { // if 1 or more results, display them
             for (var i = 0; i < len; i++) {
            var featureAttributes = results.features[i].attributes;
            var dater = results.fields[k].type;
              for (att in featureAttributes) {
                //featureAttributes.EDITEDDATE = new Date(featureAttributes.EDITEDDATE);
                 //featureAttributes.CREATEDDATE = new Date(featureAttributes.CREATEDDATE);
                 //featureAttributes.CMEMODAT = new Date(featureAttributes.CMEMODAT);
                 //featureAttributes.DATOFACQ = new Date(featureAttributes.DATOFACQ);
            s = s + "<tr><td><span style='white-space: nowrap'>" + "<b>" + (aliases.hasOwnProperty(att) && aliases[att]) + "</b>" + ": " + "</td><td style='width:100%;'>" + featureAttributes[att] + "</td></tr>";
            }
            s = s + "</table><br>";
           }        
         }


In the code above, it works fine for the first att in my list but the next one does not get inclused and built in the table.

I have hacke dit around as i have had to make it work for IE and am struggling to see where my table is not working on the second attribute...any ideas where im going wrong in that html build?

I am also trying ot find all datetype fields,
var dater = results.fields[k].type;

Can i build this into the loop like

if (dater == "esriFieldTypeDate") {} etc?

Outcomes