We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Paging record count

Hi,
New to these controls so please excuse any idiocy.
I have some data coming in from an ajax call and it is has the total record count embedded in the data as a column.  This is all fine and the grid renders it no issues.  However I need to be able to tell the grid the number of records that are present so that the pager can be adjusted.  I have tried all sorts - adding count as a variable to an object along with the array of values.  Nothing works.  As an example taken from your own examples I have the following using which I want to pretend that there are 50 records total - 3 are downloaded...

    <div id='Grid'></div>
    <script>
      var shipDetails = [
        {Name: 'Hanari Carnes', City: 'Brazil', test:true },
        {Name: 'Split Rail Beer & Ale', City: 'USA', test:true },
        {Name: 'Ricardo Adocicados', City: 'Brazil' }
      ];
      
      var test = {
        result: shipDetails, 
        count: 50 
      };
      var dataManager = ej.DataManager(test);
      
      $(function () {
        $('#Grid').ejGrid({
          dataSource: dataManager,
          allowPaging : true,
          pageSettings: {
            pageSize:2, showDefaults: false }
        });
      });
    </script>

1 Reply

VA Venkatesh Ayothi Raman Syncfusion Team October 5, 2016 09:39 AM UTC

Hi Jon, 

Thanks for contacting Syncfusion support. 

If we use pager template, then we will handle the pager operation programmatically. We can customize the pager template for showing the current page records of total records count. Please refer to the code example and sample, 
Code example: 
<GRID>        
     $("#Grid").ejGrid({ 
               dataSource: data, 
                allowPaging: true, 
                allowSorting: true, 
                actionComplete: 'complete', 
                pageSettings: { 
                    enableTemplates: true, 
                    template: “<div class='e-pagercontainer' id='showRecords'><span></span></div>", 
                    showDefaults: false 
                }, 
                
                columns: [ 
                   .  .   . 
                ] 
            }); 
<Action Complete event> 
 
function complete(args) { 
          
                        . . . 
                     $("#showRecords").find('span').text('Showing'+' '+ this.model.pageSettings.pageSize+ ' ' +'of' +' '+ this.model.pageSettings.totalRecordsCount +' '+ "records"); 
            $("#currentPage").val(this.model.pageSettings.currentPage); 
               . . . 
     } 
 
<CSS for showing pager details in right most border of parger container > 
 
<style> 
        . . . 
        #showRecords{ 
              background-color: white; 
              } 
                      
. . . 
              .e-pagercontainer #showRecords{ 
                  float:right; 
                 margin-left:800px; 
              } 
    </style> 
 
   
Regards, 
Venkatesh Ayothiraman. 


Loader.
Up arrow icon