downloadCSVReturns: grid object

Download grid data in Comma Separated Values (CSV) format.

Parameters

NameTypeDescription
filename {string} name of the generated file.
includeAllRecords {boolean} include records that are not visible when you are using local dataSource.

Examples

Local Data

    
 <button onclick="grid.downloadCSV()" class="gj-button-md">Download Only First Page</button>
 <button onclick="grid.downloadCSV('myfilename.csv', true)" class="gj-button-md">Download All Data</button>
 <br/><br/>
 <table id="grid"></table>
 <script>
     var data, grid;
     data = [
         { 'ID': 1, 'Name': 'Hristo Stoichkov', 'PlaceOfBirth': 'Plovdiv, Bulgaria' },
         { 'ID': 2, 'Name': 'Ronaldo Luis Nazario de Lima', 'PlaceOfBirth': 'Rio de Janeiro, Brazil' },
         { 'ID': 3, 'Name': 'David Platt', 'PlaceOfBirth': 'Chadderton, Lancashire, England' }
     ];
     grid = $('#grid').grid({
         dataSource: data,
         columns: [ { field: 'ID', width: 56 }, { field: 'Name' }, { field: 'PlaceOfBirth' } ],
         pager: { limit: 2, sizes: [2, 5, 10, 20] }
     });
 </script>

  

Remote Data

    
 <button onclick="grid.downloadCSV('myfilename.csv')" class="gj-button-md">Download CSV</button>
 <br/><br/>
 <table id="grid"></table>
 <script>
     var grid = $('#grid').grid({
         dataSource: '/Players/Get',
         columns: [ { field: 'ID', width: 56 }, { field: 'Name' }, { field: 'PlaceOfBirth' } ],
         pager: { limit: 5 }
     });
 </script>