Pager Overview

The KendoReact Pager provides options for splitting content into pages.

The KendoReact Pager is part of the KendoReact library of React UI components. It is distributed through NPM under the kendo-react-data-tools package.

Basic Usage

You can configure the Pager by using the following properties:

  • buttonCount—Sets the maximum numeric buttons count before the buttons are collapsed.
  • info—Toggles the information about the current page and the total number of records.
  • type—Accepts the numeric (buttons with numbers) and input (input for typing the page number) values.
  • pageSizes—Displays a menu for selecting the page size.
  • previousNext—Toggles the Previous and Next buttons.
import React from 'react';
import ReactDOM from 'react-dom';
import { Pager } from '@progress/kendo-react-data-tools';
import { DemoConfigurator } from './configurator.jsx';
import { products } from './products.js';

class App extends React.Component {
    total = products.length;
    pageSizes = [5, 10, 20];

    state = {
        skip: 0,
        take: 5,
        buttonCount: 5,
        type: 'numeric',
        info: true,
        pageSizes: true,
        previousNext: true
    };

    render() {
        const { skip, take, ...rest } = this.state;

        console.log(products.slice(skip, skip + take));
        return (
            <React.Fragment>
                <DemoConfigurator
                    onChange={data => this.setState(data)}
                    values={rest}
                />
                <Pager
                    skip={skip}
                    take={take}
                    total={this.total}
                    buttonCount={this.state.buttonCount}
                    info={this.state.info}
                    type={this.state.type}
                    pageSizes={this.state.pageSizes ? this.pageSizes : undefined}
                    previousNext={this.state.previousNext}
                    onPageChange={this.handlePageChange}
                />
            </React.Fragment>
        );
    }

    handlePageChange = event => {
        const { skip, take } = event;
        this.setState({ skip, take });

        console.log(`Page Change: skip ${skip}, take ${take}`);
    };
}

ReactDOM.render(
    <App />,
    document.querySelector('my-app')
);

Responsive Design

The Pager supports responsive web-design by adapting its layout based on the set width or the available screen size.

There are three breaking points which determine the visibility of the internal group of elements:

  • pagerWidth >= 768px - When the Pager width is greater than or equal to 768 pixels, all elements are visible.
  • 768px < pagerWidth <= 600px - When the Pager width is less than 768px, the Info element is hidden.
  • pagerWidth > 600px - When the Pager width is less than 600px, the PageSizes element is also hidden. If the Pager type is numeric, the page number buttons are replaced with a Select element.

Try to resize the browser width to see the different layouts:

import React from 'react';
import ReactDOM from 'react-dom';
import { Pager } from '@progress/kendo-react-data-tools';

class App extends React.Component {
    state = { skip: 0, take: 5 };

    render() {
        return (
            <Pager
                skip={this.state.skip}
                take={this.state.take}
                total={200}
                onPageChange={this.handlePageChange}
                buttonCount={5}
                info={true}
                previousNext={true}
                type="numeric"
                pageSizes={[10, 15, 20]}
            />

        );
    }

    handlePageChange = event => {
        this.setState({ skip: event.skip, take: event.take });
    };
}

ReactDOM.render(
    <App />,
    document.querySelector('my-app')
);

Functionality and Features

The Pager provides globalization support.