DHTMLX Docs & Samples Explorer

Paginal Output

By default all items loaded from server or created with script are shown at once. But to increasing loading speed and make perception better you can use paginal output. With paginal output only limited number of items are visible. Other items can be viewed by switching to other page(s).

Turn On/Off Paginal Output

To turn on paginal output use the following way:

  myFolders.enablePaging(10,true);

Where the first argument is a number of items per page, the second one allows dhtmlxFolders to request additional content from the server when no items are available to fill complete page (more details about dynamical loading see below).

To reset new number of items per page use enablePaging again with new number items per page. Each time you change number of items per page, dhtmlxFolders switches to the 1st page.

To turn paging off use:

  myFolders.enablePaging(false);

Turn On Ability to Load Additional Items from Server (dynamical loading)

Using the second argument of enablePaging method you can allow (true) or deny (false) dhtmlxFolders to apply for additional content to server. In case it is allowed, dhtmxFolders will send request to server using same URL which was specified in loadXML method but with additional parameter:

  • dhx_global_page - each time it has not enough items in collection to populate the last page and until this request returns 0 items.

dhx_global_page parameter will increment its value by 1 with each next request starting from the very first one (so, the first automatic request will have dhx_global_page=2)

Important: if you are going to use paging with dynamical loading please make sure you included processing of dhx_global_page into your xml producing routine. Otherwise dhtmlxFolders will get same content endless times.

How to Switch between Pages (user interface)

The first version (1.0) of dhtmlxFolders doesn't provide ready to use interface objects for managing paging, but it does provide API methods for building it. The main method for it is: goToPage(pgNum). It provides the possibility to navigate through pages. If no page number passed, then it will return to the first page.

On each call, goToPage returns value, which means the following:

  • 0 - there is no items in dhtmlxFolders object which can be displayed (this doesn't mean there is no items at all, but no items to show. Some items can be filtered out for example);
  • 1 - page was completed without request for additional content;
  • 2 - dynamical request was sent to server, as page had no enough content and dynamical loading was on.

The same values are returned by enablePaging method.

Version 1.1 of dhtmlxFolders includes some universal solution. Only one thing you need to decide - where to put pages. You can specify the object on page which will be parent element for pages using setPagerContainer(object ID or object).

Other methods which can be useful while working with paging:

  • getCurrentPage - returns the current page;
  • getNumberOfPages - returns number of pages.