Check documentation for the latest version of dhtmlxSuite Paging DHTMLX Docs

Available only in PRO Edition


The stated functionality requires PRO version of the dhtmlxGrid (or DHTMLX Suite) package and doesn't work with the Smart Rendering mode enabled.

dhtmlxGrid supports paging through the items in the data source.

You enable and configure paging with the enablePaging() method.

mygrid = new dhtmlXGridObject("gridbox");

The parameters are:

  • mode - (boolean) enable/disable paging mode
  • pageSize - (number) count of rows per page
  • pagesInGrp - (number) count of visible page selectors
  • pagingControlsContainer - (string,number) ID or container which will be used for showing paging controls
  • showRecInfo - (boolean) enable/disable showing of additional info about paging state
  • pagingStateContainer - (string,number) ID or container which will be used for showing paging state

Setting the page

To make the desired page active, call the method changePage():

mygrid.changePage(pageNum);//numbering starts at 1

You can also use the changePageRelative(ind) method to 'open' the desired page. As a parameter the method takes relative shifting (in pages) from the currently active page.



The library provides 3 skins for paging:

  • default;
  • bricks;
  • toolbar.

Default skin





    mygrid.setPagingSkin("toolbar", "dhx_skyblue");


To localize the paging bar into some language, you should use the property i18n.paging.
The set locale is applied to all skins.

      records:"Records from ",
      to:" to ",
      page:"Page ",
      perpage:"rows per page",
      first:"To first Page",
      previous:"Previous Page",
      found:"Found records",
      next:"Next Page",
      last:"To last Page",
      of:" of ",
      notfound:"No Records Found" 

Customizing the default skin

The default skin creates 2 information lines:

  • a line with info about the current state of paging;
  • a line with navigation controls.

Both lines can be configured through templates:


The default definitions of the lines templates are shown below:

[prevpages:<: ] [currentpages:, ] [nextpages:>: ]
Results <b>[from]-[to]</b> of <b>[total]</b>

In templates you can use the following markers:

  • [from] - the index of the first row in the grid;
  • [to] - the index of the last row in the grid;
  • [total] - the total count of rows in the grid;
  • [current] - a link to the current page (or next / prev - the relative position can be used);
  • [prevpages] - a link to the previous set of pages;
  • [nextpages] - a link to the next set of pages;
  • [currentpages] - renders the current set of pages.

Any of the markers allows you to specify text for it as: [marker:text_in_normal_state:text_in_disabled_state]

[prevpages:<:No Previous Pages]

You can use any combination of markers and static text/HTML inside the templates:

mygrid.setPagingTemplates("Pages - [current:0] 
     [current:+1] [current:+2] , from [total] rows","");

Customizing the 'bricks' skin

The user can adjust the necessary class in order to change the look and feel of controls:

  • .dhx_pbox - a border line around navigation controls;
  • .dhx_pline - an area with page buttons;
  • .dhx_page - a navigation button;
  • .dhx_pager_info - an area with information about the current position inside paging;
  • .dhx_page_active - an active page button.

There are also different styles for different grid skins:

  • .dhx_pbox_skyblue - default skin;
  • .dhx_pbox_web - web skin;
  • .dhx_pbox_terrace - terrace skin;
  • etc.

Customizing the 'toolbar' skin

The toolbar skin is based on dhtmlxToolbar. To get the toolbar object you should use the aToolBar property. Note, the property is available only after all rows are loaded.

   var myToolbar=grid.aToolBar;

Now you can apply to the myToolbar object any of the dhtmlxToolbar methods.

In addition to that, the users can also configure which buttons (among the default ones) they expect to see in the toolbar:


Each of the above mentioned parameters can be set either to true or false:

  • navButtons - the first, prev, next, last buttons;
  • navLabel - the label with information about the currently shown pages;
  • pageSelect - the selectbox that allows choosing the current page;
  • perPageSelect - the selectbox that allows choosing the count of rows per page.

The user can change the style of the "tooblar" paging skin using the 2nd parameter of the setPagingSkin() method:


Creating a custom skin

If none of the built-in skins meets your needs, you can easily create a custom one. Basically, some custom code can be attached to events of the grid, but paging provides more simple way to define custom skins. Just define a grid method with the name:


And call the following method:


As a result, this new grid method will be called each time when some paging information is changed and needs to be updated.

For example, creating a group of paging controls like this:

<input type="button" value="Previous">
<span>Current page: NN</span>
<input type="button" value="Next">

This can be done in the following way:

    /* page - the current page
        start - the first visible row
        last - the last visible row */
    var html='<input type="button" value="Previos"><span>Current page: '+page
      +'</span><input type="button" value="Next">';
    mygrid._pgn_parentObj.childNodes[0].onclick=function() { // the previous button logic
    mygrid._pgn_parentObj.childNodes[2].onclick=function() { // the next button logic

Integrating a paged grid with DHTMLX containers

It's possible to add paging in Status Bar of the container components.

For example, let's assume that you already have an initialized component with a cell.

First, you should attach Status Bar. For this purpose, you have to set the paging param to true:

var pagingId = "pagingArea_"+window.dhx.newId();
    text: "<div id='"+pagingId+"'></div>",
    paging: true

Then you need to enable paging in the grid:

var myGrid = cell.attachGrid();
// more config here if needed
myGrid.enablePaging(true, 9, 3, pagingId);

You can have a look at the related samples by this link.

Back to top