Select to view content in your preferred language

Export Dojo Datagrid Results to .csv File?

9775
23
01-09-2012 05:50 AM
EmilyLaMunyon
Deactivated User
Hello,

Does anyone have advice on how to export the contents of a dojo.datagrid to a .csv file or excel spreadsheet? I am needing this function in my Javascript API web mapping application.

Thanks!
0 Kudos
23 Replies
HemingZhu
Frequent Contributor
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> 




Are you using the python script tabletoexcel.py that i pointed to? if so, here is how i modified it to fit my use. I added Make Feature Layer (or Make Table View) with the Query Expression (the same as you use query task's where clause). then use the result feature layer or table view (in your case would be data store) as the first input for the tabletoexcel.py and published it as a GP service (i also include a zip module to zip the result).
0 Kudos
EmilyLaMunyon
Deactivated User
Heming,

Before I use the example you provided, I am trying to use the following sample. I have it working, the problem is that only one result is being exported from the data store. I think it has to do with the feature attributes returning only one result. Does an Identify Task return a Feature Set?

http://arcscripts.esri.com/details.asp?dbid=16528

 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;
        alert(feature.attributes);
           
        if (result.layerName =="surveys"){
     showSurveysNameGrid();
        
  feature.setSymbol(polygonSymbol);
     //searchType="selSurvey";
   //for (var i = 0; i < feature.length; i++) {
    //alert(result.feature);
        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);
    }


0 Kudos
HemingZhu
Frequent Contributor
Heming,

Before I use the example you provided, I am trying to use the following sample. I have it working, the problem is that only one result is being exported from the data store. I think it has to do with the feature attributes returning only one result. Does an Identify Task return a Feature Set?

http://arcscripts.esri.com/details.asp?dbid=16528

 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;
        alert(feature.attributes);
           
        if (result.layerName =="surveys"){
     showSurveysNameGrid();
        
  feature.setSymbol(polygonSymbol);
     //searchType="selSurvey";
   //for (var i = 0; i < feature.length; i++) {
    //alert(result.feature);
        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);
    }




Identify task return identifyResults. which is a litttle different from featureSet retured from Query Task. What are common among them is that they all include features. For identifyResults, you have to regroup features based on layer id or name so that you are the same as as QueryTask's featureSet that can be used in a GP service as featureSet (or featureLayer).
0 Kudos
BrianLord1
Deactivated User
There is a python script in http://resources.arcgis.com/gallery/file/geoprocessing/details?entryID=95009B25-1422-2418-7FB5-B8638.... You can easily modify it and use it as a GP Service. I personally used it to convert  a query results (FeatureSet) to CSV or .XLS file.


I know this has been idle for a while, but I am stuck.

What do I have to modify within the python script so that I can use it as a geoprocessing service to export data from a datagrid?

Thanks,
Mark
0 Kudos
VinayBansal
Frequent Contributor
I have taken this approach for exporting the data to csv from datagrid.

Added a form in page with hidden attribute and set its action to handler

[HTML]<form id="csvForm" action="Handlers/MyWebHandler.ashx?module=ExportToExcel" method="post">
<input type="hidden" value=""  id="csvdata" name="csvdata" />
<input type="hidden" value=""  id="title" name="title" />
</form>[/HTML]

Then  in js function is written to get the grid data.
function exportCSVData() {
        var gridData = dijit.byId("grid");
        var csvdatafield = dojo.byId("csvdata");
        var csvText = "";
        var fields = gridData.structure[0].cells[0];
        if (fields != null && fields.length > 0) {
            for (var ifldCnt = 0; ifldCnt < fields.length; ifldCnt++) {
                if (ifldCnt == 0) {
                    csvText = fields[ifldCnt].name;
                } else {
                    csvText += "," + fields[ifldCnt].name;
                }

            }
            csvText += "\n";
            var fieldValue = "";

            for (var i = 0; i < gridData.rowCount; i++) {
                var featureAttribute = gridData.store._arrayOfAllItems;
                var columnVal;
                for (var ifldCnt = 0; ifldCnt < fields.length; ifldCnt++) {
                    fieldValue = "";

                    //columnVal = this.getValuefromAttribute(featureAttribute[fields[ifldCnt].field], false, "");
                    columnVal = featureAttribute[fields[ifldCnt].field][0];
                    if (columnVal != null && columnVal != "")
                        fieldValue = columnVal;

                    if (isNaN(fieldValue)) {
                        if (fieldValue.indexOf('\'') != -1 || fieldValue.indexOf('\"') != -1 || fieldValue.indexOf(',') != -1) {
                            if (fieldValue.indexOf('\"') != -1) {
                                fieldValue = fieldValue.replace("\"", "\"\"");
                            }
                            fieldValue = "\"" + fieldValue + "\"";
                        }
                    }
                    if (ifldCnt == 0)
                        csvText += fieldValue;
                    else
                        csvText += "," + fieldValue;

                }
                csvText += "\n";
            }
            if (csvText != "")
                csvText = escape(csvText);
            csvdatafield.value = csvText;  // After value is set for the hidden field submit the form
            var formCSV = dojo.byId("csvForm");
            formCSV.submit();

        }
    }


Once the form is submitted, the control is passed to handler, that will fetch the data from form submitted and create csv

In handler get the attributes "MyWebHandler.ashx"
public void ProcessRequest(HttpContext context)
    {
        context.Response.ContentType = "text/plain";
        System.Collections.Specialized.NameValueCollection parameters = context.Request.Form;
        string moduleName = parameters["module"];
        
        ExportHelper objExportCSVHelper = new ExportHelper();
        objExportCSVHelper.ExportToCSV(parameters["csvdata"].ToString(), HttpContext.Current, parameters["title"].ToString());
               


    }

And in ExportHelper class write the ExportToCSV Function
 public void CSV2Excel(string strCSV, HttpContext current, string strTitle)
        {
            current.Response.Clear();
            strCSV = removeUniCodeSequenceCharacters(strCSV);
            strCSV = System.Text.RegularExpressions.Regex.Unescape(strCSV);
            current.Response.AddHeader("content-disposition", "attachment;filename=" + strTitle +"_"+DateTime.Now.ToString("ddmmyyyyHHMMSS") + ".csv");
            current.Response.Charset = "";
            current.Response.ContentType = "application/octet-stream";
            current.Response.Write(strCSV);
            current.Response.End();

        }
//Since we used escape to send text from javascript to Server side we need this function
 private string removeUniCodeSequenceCharacters(string strWithEscapeSequence)
        {
            string strUse = "";
            strUse = strWithEscapeSequence.Replace("%20", " ");
            strUse = strUse.Replace("%2C", ",");
            strUse = strUse.Replace("%27", "'");
            strUse = strUse.Replace("%22", "\"");
            strUse = strUse.Replace("%3F", "?");
            strUse = strUse.Replace("%0A", "\n");
            strUse = strUse.Replace("%28", "(");
            strUse = strUse.Replace("%29", ")");
            strUse = strUse.Replace("%26", "&");
            strUse = strUse.Replace("%23", "#");
            strUse = strUse.Replace("%3A", ":");
            strUse = strUse.Replace("%21", "!");
            strUse = strUse.Replace("%2D", "-");
            strUse = strUse.Replace("%3B", ";");
            strUse = strUse.Replace("%2A", "*");
            strUse = strUse.Replace("%2B", "+");
            strUse = strUse.Replace("%2E", ".");
            strUse = strUse.Replace("%3C", "<");
            strUse = strUse.Replace("%3D", "=");
            strUse = strUse.Replace("%3E", ">");
            strUse = strUse.Replace("%40", "@");
            return strUse;
        }
0 Kudos
BrianLord1
Deactivated User
Are you using the python script tabletoexcel.py that i pointed to? if so, here is how i modified it to fit my use. I added Make Feature Layer (or Make Table View) with the Query Expression (the same as you use query task's where clause). then use the result feature layer or table view (in your case would be data store) as the first input for the tabletoexcel.py and published it as a GP service (i also include a zip module to zip the result).


Would it be possible for you to paste some code to show exactly how you implemented the gp service within your code?  What did you do for the second input?

Also, did you change anything within the actual table2excel python script?

Any help would be greatly appreciated, I have been stuck on this for a while now.

Thanks,
Mark
0 Kudos
BrianLord1
Deactivated User
I have taken this approach for exporting the data to csv from datagrid.

Added a form in page with hidden attribute and set its action to handler

[HTML]<form id="csvForm" action="Handlers/MyWebHandler.ashx?module=ExportToExcel" method="post">
<input type="hidden" value=""  id="csvdata" name="csvdata" />
<input type="hidden" value=""  id="title" name="title" />
</form>[/HTML]

Then  in js function is written to get the grid data.
function exportCSVData() {
        var gridData = dijit.byId("grid");
        var csvdatafield = dojo.byId("csvdata");
        var csvText = "";
        var fields = gridData.structure[0].cells[0];
        if (fields != null && fields.length > 0) {
            for (var ifldCnt = 0; ifldCnt < fields.length; ifldCnt++) {
                if (ifldCnt == 0) {
                    csvText = fields[ifldCnt].name;
                } else {
                    csvText += "," + fields[ifldCnt].name;
                }

            }
            csvText += "\n";
            var fieldValue = "";

            for (var i = 0; i < gridData.rowCount; i++) {
                var featureAttribute = gridData.store._arrayOfAllItems;
                var columnVal;
                for (var ifldCnt = 0; ifldCnt < fields.length; ifldCnt++) {
                    fieldValue = "";

                    //columnVal = this.getValuefromAttribute(featureAttribute[fields[ifldCnt].field], false, "");
                    columnVal = featureAttribute[fields[ifldCnt].field][0];
                    if (columnVal != null && columnVal != "")
                        fieldValue = columnVal;

                    if (isNaN(fieldValue)) {
                        if (fieldValue.indexOf('\'') != -1 || fieldValue.indexOf('\"') != -1 || fieldValue.indexOf(',') != -1) {
                            if (fieldValue.indexOf('\"') != -1) {
                                fieldValue = fieldValue.replace("\"", "\"\"");
                            }
                            fieldValue = "\"" + fieldValue + "\"";
                        }
                    }
                    if (ifldCnt == 0)
                        csvText += fieldValue;
                    else
                        csvText += "," + fieldValue;

                }
                csvText += "\n";
            }
            if (csvText != "")
                csvText = escape(csvText);
            csvdatafield.value = csvText;  // After value is set for the hidden field submit the form
            var formCSV = dojo.byId("csvForm");
            formCSV.submit();

        }
    }


Once the form is submitted, the control is passed to handler, that will fetch the data from form submitted and create csv

In handler get the attributes "MyWebHandler.ashx"
public void ProcessRequest(HttpContext context)
    {
        context.Response.ContentType = "text/plain";
        System.Collections.Specialized.NameValueCollection parameters = context.Request.Form;
        string moduleName = parameters["module"];
        
        ExportHelper objExportCSVHelper = new ExportHelper();
        objExportCSVHelper.ExportToCSV(parameters["csvdata"].ToString(), HttpContext.Current, parameters["title"].ToString());
               


    }

And in ExportHelper class write the ExportToCSV Function
 public void CSV2Excel(string strCSV, HttpContext current, string strTitle)
        {
            current.Response.Clear();
            strCSV = removeUniCodeSequenceCharacters(strCSV);
            strCSV = System.Text.RegularExpressions.Regex.Unescape(strCSV);
            current.Response.AddHeader("content-disposition", "attachment;filename=" + strTitle +"_"+DateTime.Now.ToString("ddmmyyyyHHMMSS") + ".csv");
            current.Response.Charset = "";
            current.Response.ContentType = "application/octet-stream";
            current.Response.Write(strCSV);
            current.Response.End();

        }
//Since we used escape to send text from javascript to Server side we need this function
 private string removeUniCodeSequenceCharacters(string strWithEscapeSequence)
        {
            string strUse = "";
            strUse = strWithEscapeSequence.Replace("%20", " ");
            strUse = strUse.Replace("%2C", ",");
            strUse = strUse.Replace("%27", "'");
            strUse = strUse.Replace("%22", "\"");
            strUse = strUse.Replace("%3F", "?");
            strUse = strUse.Replace("%0A", "\n");
            strUse = strUse.Replace("%28", "(");
            strUse = strUse.Replace("%29", ")");
            strUse = strUse.Replace("%26", "&");
            strUse = strUse.Replace("%23", "#");
            strUse = strUse.Replace("%3A", ":");
            strUse = strUse.Replace("%21", "!");
            strUse = strUse.Replace("%2D", "-");
            strUse = strUse.Replace("%3B", ";");
            strUse = strUse.Replace("%2A", "*");
            strUse = strUse.Replace("%2B", "+");
            strUse = strUse.Replace("%2E", ".");
            strUse = strUse.Replace("%3C", "<");
            strUse = strUse.Replace("%3D", "=");
            strUse = strUse.Replace("%3E", ">");
            strUse = strUse.Replace("%40", "@");
            return strUse;
        }


Could you please provide all the code for your MyWebHandler.ashx file?  I am trying to implement your strategy but keep getting errors in that file.  I assume I missed some code or something so if you could provide the entire code for that file it would be greatly appreciated.

Thanks,
Mark
0 Kudos
VinayBansal
Frequent Contributor
Could you please provide all the code for your MyWebHandler.ashx file?  I am trying to implement your strategy but keep getting errors in that file.  I assume I missed some code or something so if you could provide the entire code for that file it would be greatly appreciated.

Thanks,
Mark


MyWebHandler.ashx has only one method as mentioned in my above post. And this is how the method is called of ExportHelper

 
public void ProcessRequest(HttpContext context)
    {
        context.Response.ContentType = "text/plain";
        System.Collections.Specialized.NameValueCollection parameters = context.Request.Form;
        string moduleName = parameters["module"];
        string requestFeedback = "";
        switch (moduleName)
        {

            case "ExportToExcel":
                EgisWeb.ExportHelper objExportCSVHelper = new EgisWeb.ExportHelper();
                objExportCSVHelper.CSV2Excel(parameters["csvdata"].ToString(), HttpContext.Current, parameters["title"].ToString());
                break;
           

        }
        if (moduleName != "ExportToExcel")

            context.Response.Write(requestFeedback);


    }
0 Kudos
BrianLord1
Deactivated User
I finally got my export functionality to work.  I went kind of along the same lines as mentioned above, but got the exact code from a post on gis.stackexhange.

Here is the link to that thread in case this could help someone else.
http://gis.stackexchange.com/questions/67862/export-dojo-datagrid-results-to-csv-in-javascript-web-a...

Thanks,
Mark
0 Kudos
TracySchloss
Honored Contributor
I found this thread very helpful and was able to get 99% of the way through my print issue.  I'm trying to print not from just one grid, but several, created as a result of executing a series of querytasks on multiple layers. 

I decided it was acceptable to have one CSV file for all the grid output and I'll rely on the users ability to copy/paste the output into separate work sheets or separate files as needed.

My problem is within the function that is supposed to format the data. Somewhere in this code, I'm introducing something that translates into a column shift in the output CSV (I assume a comma).  Viewed in Excel, for the first grid the field names start in column A , but all the data that corresponds with it starts in column B, shifted over one column to the right.

When I process all subsequent grids, both fields and data start in column B, with nothing in column A.  At least for these the names and data line up!

Have I taken a simple task and made it complicated?  My output looks right, except for the shift in the columns.
function exportGridCSV() {
 dataArray.length = 0;
 var fieldValue;
 var fieldNames = [];
//qTaskNameList created from query task that populated the grids
 dojo.forEach(qTaskNameList, function(gridName) {
  var gridData = dijit.byId(gridName+"_grid");
  var gridLength = gridData.rowCount;
        var fields = gridData.layout.cells;
  var fieldNames.length = 0;
  //populates an array with the field names used to find the values in the data store
  dojo.forEach(fields, function (field) {
   fieldNames.push(field.field);  
   dataArray.push(field.field);
  });
  dataArray.push("\r");//first line is the field names
  
  if (gridLength > 0) {//don't try to export if there were not values in that grid
  var gridStore = gridData.store._arrayOfAllItems;//the store of one grid
 //for each record, populates the array with the values for the fields stored in the field array
  for (var i=0; i< gridStore.length; i++) {
   var gridRec = gridStore;
   var j = 0;
   dojo.forEach (fieldNames, function(fieldName) {
    fieldValue = gridRec[fieldName];
    if (isNaN(fieldValue)) {//for data containing slashes
                        if (fieldValue.indexOf('\'') != -1 || fieldValue.indexOf('\"') != -1 || fieldValue.indexOf(',') != -1) {
                            if (fieldValue.indexOf('\"') != -1) {
                             fieldValue = fieldValue.replace("\"", "\"\"");
                            }
                            fieldValue = "\"" + fieldValue + "\"";
                    }
                   }
   dataArray.push(fieldValue);
    j++;
   });
  dataArray.push("\r");
  }//end of record
 dataArray.push("\r"); //puts an empty row before the next set of records
  }
 });
submitCSVprint();
}
function submitCSVprint() {
//opens the data in a hidden form used for printing and allows the user to either open or save the file.
var url = "webservices/csv.ashx";
var data = dataArray.join();
var f = dojo.byId("downloadForm");
f.action = url;
dojo.byId("reportinput").value = data;
var distType = dijit.byId("distTypeSelect").value;
var distNum = dojo.byId("txtDistNumber").value;
dojo.byId("filename").value = distType+"_Dist_"+distNum+"_";
f.submit();
}
0 Kudos