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.
Unfortunately, activation email could not send to your email. Please try again.

Paging record count

Thread ID:

Created:

Updated:

Platform:

Replies:

126253 Oct 4,2016 07:14 AM Oct 5,2016 05:39 AM JavaScript 1
loading
Tags: ejGrid
Jon E
Asked On October 4, 2016 07:14 AM

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>

Venkatesh Ayothi Raman [Syncfusion]
Replied On October 5, 2016 05:39 AM

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. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;