Return an array with all records presented in the grid.
Examples
remote data
<button id="btnGetAllName">Get All Names</button>
<br/><br/>
<table id="grid"></table>
<script>
var grid = $('#grid').grid({
dataSource: '/0_6/Grid/GetPlayers',
columns: [ { field: 'ID' }, { field: 'Name' }, { field: 'PlaceOfBirth' } ]
});
$('#btnGetAllName').on('click', function () {
var records = grid.getAll(), names = '';
$.each(records, function () {
names += this.Name + '(id=' + this.ID + '),';
});
alert(names);
});
</script>
local data
<button id="btnAdd">Add New Row</button>
<br/><br/>
<table id="grid"></table>
<script>
var grid = $('#grid').grid({
dataSource: [
{ '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' }
],
autoGenerateColumns: true
});
$('#btnAdd').on('click', function () {
grid.getAll().push({ 'ID': grid.count() + 1, 'Name': 'Test Player', 'PlaceOfBirth': 'Test City, Test Country' });
grid.reload();
});
</script>