I am getting close. The problem is that only one result, the last one, from my datagrid is showing up in my text area for export to excel. I think the csv is not getting the full results from the feature selected, for some reason it only gets one. How do I get the full results of the selection ready for csv export?
function executeIdentifyTask(geom) {
//clear the graphics layer
map.graphics.clear();
identifyParams.geometry = geom;
identifyParams.mapExtent = map.extent;
identifyTask.execute(identifyParams,function(response){
var polygonSymbol = 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,94,204,0.8]));
var markerSymbol = new esri.symbol.SimpleMarkerSymbol().setColor(new dojo.Color([25,50,225,0.3]));
var controlItems = [];
var surveyItems = [];
dojo.forEach(response,function(result){
var feature = result.feature;
if (result.layerName =="surveys"){
showSurveysNameGrid();
feature.setSymbol(polygonSymbol);
var attributes = feature.attributes;
surveyItems.push(attributes);
var csvTextSurv = "DOCUMENT_N;TOWNSHIP_RANGE;SECTION\n";
csvTextSurv += attributes["DOCUMENT_N"] + ";" +
attributes["TOWNSHIP_RANGE"] + ";" +
attributes["SECTION"] + "\n";
document.getElementById("csvSurv").value = csvTextSurv;
map.graphics.add(feature);
}else{
showPointNameGrid();
feature.setSymbol(markerSymbol);
var attributes = feature.attributes;
controlItems.push(feature.attributes);
var csvTextMons = "POINT_NAME;SECTION\n";
csvTextMons += attributes["POINT_NAME"] + ";" +
attributes["TOWNSHIP_RANGE"] + ";" +
attributes["SECTION"] + "\n";
}
document.getElementById("csvMons").value = csvTextMons;
map.graphics.add(feature);
});
if(surveyItems.length >0){
showSurveysNameGrid();
var surveysStore = new dojo.data.ItemFileReadStore({data:{identifier:'DOCUMENT_N',items:surveyItems}});
var grid = dijit.byId('grid5');
grid.setStore(surveysStore);
}
if(controlItems.length >0){
showPointNameGrid();
var controlStore = new dojo.data.ItemFileReadStore({data:{identifier:'POINT_NAME',items:controlItems}});
var grid = dijit.byId('grid4');
grid.setStore(controlStore);
}
});
}
<div id="footerPoints" class="roundedCorners" dojotype="dijit.layout.ContentPane" region="bottom" style=" padding-bottom:5%; height:18%; display:none">
<form action="http://surveyor.slco.org/JSAPIExportToExcel/DojoGridToExcel.asmx/CSV2Excel " method="POST">
<textarea name="csv" id="csvMons" style="width: 500px; height:30px"></textarea>
<input type="submit" value="Submit" />
</form>
<table dojotype="dojox.grid.DataGrid" data-dojo-id="grid4" id="grid4" data-dojo-props="rowsPerPage:'5', rowSelector:'20px'">
<thead>
<tr>
<th field="POINT_NAME" width="200px" >
Point Name
</th>
<th field="GRID_ADDRESS" width="200px" >
Address
</th>
<th field='TOWNSHIP_RANGE' width='200px'>Township/Range</th>
<th field="SECTION" width="200px" >
Section
</th>
<th fields="POINT_NAME,LONGITUDE_DD,LATITUDE_DD" formatter="makeLink1" width="200px" >
Monument Reference Sheet
</th>
<th field="MON_NOTES" width="200px" >
Monument Notes
</th>
</tr>
</thead>
</table>
</div>
<div id="footersurvName" class="roundedCorners" dojotype="dijit.layout.ContentPane" region="bottom" style=" padding-bottom:5%; height:18%; display:none">
<form action="http://surveyor.slco.org/JSAPIExportToExcel/DojoGridToExcel.asmx/CSV2Excel " method="POST">
<textarea name="csv" id="csvSurv" style="width: 500px; height:30px"></textarea>
<input type="submit" value="Submit" />
</form>
<table dojotype="dojox.grid.DataGrid" data-dojo-id="grid5" id="grid5" data-dojo-props="rowsPerPage:'5', rowSelector:'20px'">
<thead>
<tr>
<th field="DOCUMENT_NUM" width="200px" >
Survey Number
</th>
<th field="SURVEYOR" width="200px" >
Surveyor
</th>
<th field="ADDRESS_OF_SURVEY" width="200px" >
Address
</th>
<th field='TOWNSHIP_RANGE' width='200px'>
Township/Range
</th>
<th field="SECTION" width="200px" >
Section
</th>
<th fields="subdir,page_id" formatter="makeLink" width="200px" >
PDF
</th>
</tr>
</thead>
</table>
</div>