Not sure how to go about this. We need to be able to export the data in the data grid to excel or csv. Our application will be used on PC and tablets. I thought the EnhancedGrid might be the answer with the dojox.grid.enhanced.plugins.exporter.CSVWriter. However, I'm not having much luck. I thought I would just need to do this since my datagrid was already loaded with the correct data:1.) Add plugins { exporter: true } to my datagrid but not sure how to do this.2.) Add this functions to the script function exportAll(){ dijit.byId("gridCE").exportGrid("csv", function(str){ dojo.byId("output").value = str; });};function exportSelected(){ var str = dijit.byId("gridCE").exportSelected("csv"); dojo.byId("output").value = str;};3.) Create buttons<button onclick="exportAll()">Export all to CSV</button><button onclick="exportSelected()">Export Selected Rows to CSV</button>4.) Add references "dojox/grid/EnhancedGrid", "dojox/data/CsvStore", "dojox.grid.enhanced.plugins.exporter.CSVWriter"Current Data Grid.
<button onclick="exportAll()">Export all to CSV</button>
<button onclick="exportSelected()">Export Selected Rows to CSV</button>
<table data-dojo-type="dojox.grid.EnhancedGrid" jsid="gridCE" id="gridCE" selectionMode="single">
<thead>
<tr>
<th field="FID" formatter="makeZoomButton" width="30px">
<img alt="+" src="assets/images/GenericSearch32.png"/>
</th>
<th field="FID" width="100px">FID</th>
<th field="DIVISIONNA" width="100px">DIVISIONNA</th>
<th field="GSF" width="60px">GSF</th>
<th field="OPENED" width="100px">OPENED</th>
<th field="TYPE" width="70px">TYPE</th>
<th field="MALLNAME" width="200px">MALLNAME</th>
<th field="MALL_GRADE" width="70px">MALL GRADE</th>
<th field="DISTRICT" width="150px">DISTRICT</th>
<th field="MACYS_MALL" width="100px">MACYS_MALL</th>
<th field="WebLon_X" width="100px">WebLon_X</th>
<th field="WebLat_Y" width="100px">WebLat_Y</th>
</tr>
</thead>
</table>
Shortened code for putting into data grid:
var emptyCells = { items: "" };
var emptyStore = new dojo.data.ItemFileWriteStore({data: emptyCells});
grid = dijit.byId('gridCE');
grid.setStore(emptyStore);
//Put values in array for datagrid
var attValues = resultFeatures.attributes;
dataForGrid.push(attValues);
};
var data = {
identifier : "FID",
label : "FID",
items : dataForGrid
};
var store = new dojo.data.ItemFileReadStore({data: data});
grid.setSortIndex(2,"true"); //sort on the state name
grid.setStore(store);