Get grid data in Comma Separated Values (CSV) format.
Parameters
Name | Type | Description |
---|---|---|
includeAllRecords | {boolean} | include records that are not visible when you are using local dataSource. |
Examples
Local Data
<button onclick="alert(grid.getCSV(true))" class="gj-button-md">Get All</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="alert(grid.getCSV())" class="gj-button-md">Get 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>