React TreeList - Paging

Paging improves the UI component's performance on large datasets because it renders rows by pages instead of rendering them at once. To enable paging, set the paging.enabled property to true. Use the pageSize property to change the number of rows per page. You can also specify which page to display by default using the pageIndex property.

JavaScript
  • $(function () {
  • $("#treeListContainer").dxTreeList({
  • // ...
  • paging: {
  • enabled: true,
  • pageSize: 15,
  • pageIndex: 1 // Shows the second page
  • }
  • });
  • });

User Interaction

This section describes how to configure the pager - a component that allows users to navigate through pages and change their size at runtime. The pager consists of the page navigator and several optional elements: the page size selector, navigation buttons, and page information.

DevExtreme HTML5 JavaScript jQuery Angular Knockout UI component TreeList Pager

Set the showNavigationButtons and the showPageSizeSelector properties to true to show the navigation buttons and the page size selector. The set of available page sizes depends on the size of the data source. You can change this set using the allowedPageSizes property.

JavaScript
  • $(function () {
  • $("#treeListContainer").dxTreeList({
  • // ...
  • pager: {
  • showPageSizeSelector: true,
  • allowedPageSizes: [10, 20, 50],
  • showNavigationButtons: true
  • }
  • });
  • });

Assign true to the showInfo property to show the page information. You can change the default text by specifiyng the infoText.

JavaScript
  • $(function () {
  • $("#treeListContainer").dxTreeList({
  • // ...
  • paging: { enabled: true }
  • pager: {
  • showInfo: true,
  • infoText: "Page #{0}. Total: {1} ({2} items)"
  • }
  • });
  • });

View Demo

API

Call the pageCount() method to get the total page count.

JavaScript
  • var totalPageCount = $("#treeListContainer").dxTreeList("instance").pageCount();

The TreeList also provides the pageIndex(newIndex) and pageSize(value) methods that switch the UI component to a specific page and change the page size. They can also be called without arguments, in which case, they return the current page's index and size.

JavaScript
  • $("#treeListContainer").dxTreeList("instance").pageSize(8);
JavaScript
  • var goToLastPage = function (treeListInstance) {
  • treeListInstance.pageIndex(treeListInstance.pageCount() - 1);
  • }
See Also