elove

Populate CSV Output Question

Discussion created by elove on Sep 7, 2012
Hi,

I am trying to populate a text area with values from my Identify task in order to be exported to a csv file. I have it working, however, only one value of my Identify result is populating the csv test area, I would like ALL results to be available for export. I believe it has to do with the way I am looping through the results, but am unable to pinpoint the exact issue, any insight would be greatly appreciated!

function executeIdentifyTask(geom) {
        //clear the graphics layer 
        map.graphics.clear();
        var polygonSymbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID, new esri.symbol.SimpleLine         Symbol(esri.symbol.SimpleLineSymbol.STYLE_DOT, new dojo.Color([51, 49,0,.80]), 3), new dojo.Color([251, 149, 0, 0.45]));
        var markerSymbol = new esri.symbol.SimpleMarkerSymbol().setColor(new dojo.Color([25,50,225,0.3])); 
        
        identifyParams.geometry = geom;
        identifyParams.mapExtent = map.extent;
        identifyTask.execute(identifyParams,function(response){
        var surveyItems = [];
            
        dojo.forEach(response,function(result){
             var feature = result.feature;
              //add selected feature to graphics layer
              feature.setSymbol(polygonSymbol);
    
       var attributes = feature.attributes;
              var csvTextSurv = "DOCUMENT_N;TOWNSHIP_RANGE;SECTION\n";  
  
   // Fill table2csv
   csvTextSurv += attributes["DOCUMENT_N"] + ";" +
                               attributes["TOWNSHIP_RANGE"] + ";" +
                               attributes["SECTION"] + "\n";
                               
               document.getElementById("csvSurv").value = csvTextSurv; 
         map.graphics.add(feature);

                
                if(result.layerName === 'surveys'){
                   surveyItems.push(feature.attributes);
     showSurveysNameGrid();
     searchType="selSurveys2";
                }
           });
          
            //update the data grid 
            var surveysStore = new dojo.data.ItemFileReadStore({data:{identifier:'DOCUMENT_N',items:surveyItems}});
            var grid = dijit.byId('grid5');
            grid.setStore(surveysStore);
          
           });
}

Outcomes