title: Kendo ui Grid export to Excel and CSV using javascript
body: <p>please help me my probs,am using kendo ui grid in my webapp &amp; trying to grid data export into EXcel and CSV format. Code Works good in Chrome and files are downloading, but in Fire Fox its open a new window show the grid details in url and says bad request,</p>
  
  <p>//code is</p>
  
  <pre><code>$("#exportcsv").click(function (e) {
             debugger
             var dataSource = $("#grid").data("kendoGrid").dataSource;
  
             var filteredDataSource = new kendo.data.DataSource({
                 data: dataSource.data(),
                 filter: dataSource.filter()
             });
  
             filteredDataSource.read();
             var data = filteredDataSource.view();
  
             //start with the desired column headers here
             var result = "\"ID\",\"EID\",\"Name\",\"Company Name\",\"Salary\",\"DID\",\"Date Of Join\"";
  
             //each column will need to be called using the field name in the data source
             for (var i = 0; i &lt; data.length; i++) {
                 result += "\n";
  
                 result += "\"" + data[i].id + "\",";
  
                 result += "\"" + data[i].EID + "\",";
  
                 result += "\"" + data[i].EName + "\",";
  
                 result += "\"" + data[i].CName + "\",";
  
                 result += "\"" + data[i].Salary + "\",";
  
                 result += "\"" + data[i].DID + "\",";
  
                 result += "\"" + data[i].DOJ + "\",";
             }
  
  
  
  
  
             if (window.navigator.msSaveBlob) {
                 //Internet Explorer
                 window.navigator.msSaveBlob(new Blob([result]), 'ExportedKendoGrid.csv');
             }
  
             else if (window.webkitURL != null) {
  
                     //Google Chrome and Mozilla Firefox
                     var a = document.createElement('a');
                     result = encodeURIComponent(result);
                     a.href = 'data:application/csv;charset=UTF-8,' + result;
                     a.download = 'ExportedKendoGrid.csv';
                     a.click();
                 }
             else {
                 //Everything Else
                 window.open(result);
             }
             e.preventDefault();
         });
  </code></pre>
  
  <blockquote>
    <p>//not executing in firefox this code   else if (window.webkitURL !=
    null) {</p>
  
  <pre><code>                   //Google Chrome and Mozilla Firefox
                     var a = document.createElement('a');
                     result = encodeURIComponent(result);
                     a.href = 'data:application/csv;charset=UTF-8,' + result;
                     a.download = 'ExportedKendoGrid.csv';
                     a.click();
                 }
  </code></pre>
  </blockquote>