countReturns: number

Return the number of records in the grid. By default return only the records that are visible in the grid.

Parameters

NameTypeDescription
includeAllRecords {boolean} include records that are not visible when you are using local dataSource.

Examples

Local DataSource

    
 <button class="btn btn-default" onclick="alert(grid.count())">Count Visible Records</button>
 <button class="btn btn-default" onclick="alert(grid.count(true))">Count All Records</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: 34 }, { field: 'Name' }, { field: 'PlaceOfBirth' } ],
         uiLibrary: 'bootstrap',
         pager: { limit: 2, sizes: [2, 5, 10, 20] }
     });
 </script>

  

Remote DataSource

    
 <button onclick="alert(grid.count())">Count Visible Records</button>
 <button onclick="alert(grid.count(true))">Count All Records</button>
 <br/><br/>
 <table id="grid"></table>
 <script>
     var grid = $('#grid').grid({
         dataSource: '/Players/Get',
         columns: [ { field: 'ID', width: 34 }, { field: 'Name' }, { field: 'PlaceOfBirth' } ],
         uiLibrary: 'bootstrap',
         pager: { limit: 2, sizes: [2, 5, 10, 20] }
     });
 </script>