Developer Programs

Learn

Docs

Pagination

Components > Displaying Data > Pagination
Use this component to...
Allow the user to view a large dataset in small chunks at a time

Overview

When your application retrieves data, the amount of data retrieved is either bounded — meaning you have at least a rough idea how much data is coming back — or the amount of data retrieved is unbounded.

When the amount of data is unbounded, it’s best to retrieve the data in discrete chunks. Retrieving data can be costly in terms of server, network, and client resources. Since you won’t know which parts of the unbounded data the user is interested in (beyond any search parameters provided), it’s best not to attempt to retrieve all of the data at once.

After your app has retrieved one or more discrete chunks of data, you can use a pagination approach where one “page” of data is displayed at a time. The user is typically given options to move to the next or previous page, or even a specific page, but only one page displays at a time. This approach lends itself to displaying listings, search results, and photo galleries. Many users like to see all options at once, so offer the user a “View all” option if feasible.

Infinite scrolling is another strategy for managing large datasets that adds more data to the view whenever the user scrolls to the bottom.
Data pagination with 10 pages shown, along with Previous and Next buttons for moving through the set of pages.
Data pagination with 10 pages shown, along with Previous and Next buttons for moving through the set of pages

Development

Web component development

Component reference

rui-data-pager
rui-data-pager
Module: rui-data-pager - Package: @jkhy/responsive-ui-wc

Displays links to pages of data, indicating the current page

NameTypeDefaultDescription
pageIndexnumber11-based index of the current data page
totalItemsnumber0The total number of data items
itemsPerPagenumber10The maximum number of data items to display in a data page
maxPageButtonsnumber0

Set this to a value greater than zero if you want to cap the number of data pages shown in the pagination component. This can be useful in reducing the number of page buttons displayed in the data pager when a very large number of data items exist for the user to page through.

If greater than zero, than no more than the specified number of data page buttons display, with a range that keeps the current data page in the middle.

previousTextstring'Previous'Text displayed in the button that takes the user to the previous page of data
firstTextstring'First'Text displayed in the button that takes the user to the first page of data
nextTextstring'Next'Text displayed in the button that takes the user to the next page of data
lastTextstring'Last'Text displayed in the button that takes the user to the last page of data
isDisabledbooleanfalseSpecifies whether the data pager is disabled.
rui-data-pager-page-index-changeeventEvent fired when the data page index changes. The event detail specifies the current data page index.

Implementation

Begin by importing the rui-data-pager module into your application.

Import the module
// import into app.module
import '@jkhy/responsive-ui-wc/components/rui-data-pager/rui-data-pager-imports';

Use the rui-data-pager element for pagination.

Defining pagination
<rui-data-pager
    maxPageButtons="10"
    firstText="First"
    lastText="Last"
    previousText="Previous"
    nextText="Next"
    [totalItems]="employeeTotalCount"
    [itemsPerPage]="employeesPerPage"
    [pageIndex]="employeePageIndex"
    (rui-data-pager-page-index-change)="pageChanged($event)">
</rui-data-pager>

Angular wrapper development

Wrapper reference

ngx-bootstrap pagination
ngx-bootstrap pagination
Module: PaginationModule - Package: ngx-bootstrap

Displays links to pages of data, indicating the current page

View the ngx-bootstrap pagination reference doc

Implementation

Begin by importing the PaginationModule into your application.

Import the module
import { PaginationModule } from 'ngx-bootstrap/pagination';

@NgModule({
    imports: [
        ...
        PaginationModule.forRoot(),
        ...
    ]
})
export class AppModule(){}

Use the pagination element for pagination.

Defining pagination
<pagination class="page-bar"
    [totalItems]="EmployeeTotalCount" [itemsPerPage]="EmployeesPerPage"
    [(ngModel)]="EmployeePageIndex" (pageChanged)="pageChanged($event)">
</pagination>

Design

Figma design

Figma design info
You can find this component in the Components - Pagination page in the Figma UI Kit.
Dev ComponentDesign Component Name
Pagination first button

RUI / Pagination / First

Available values for the State property:

  • Enabled
  • Disabled
Pagination previous button

RUI / Pagination / Previous

Available values for the State property:

  • Enabled
  • Disabled
Pagination page button

RUI / Pagination / Page

Switch on the Active property for the active page in the pagination list

Pagination next button

RUI / Pagination / Next

Available values for the State property:

  • Enabled
  • Disabled
Pagination last button

RUI / Pagination / Last

Available values for the State property:

  • Enabled
  • Disabled

If you want to show an example of pagination buttons in an artboard, add an appropriate combination of Previous, page number, and Next buttons:

  • If you’re showing the first page button as active, then the Previous button is disabled but all other buttons are enabled.
  • If you’re showing a “middle” page as active, then all buttons are enabled.
  • If you’re showing the last page button as active, then the Next button is disabled but all other buttons are enabled.
  • Only show one of the page buttons as active.

Adobe XD design

Adobe XD design info
You can find this component in these artboards in the Adobe XD design samples:
  • Sample App - Large Datasets
Dev ComponentDesign Component Name
Pagination previous button - enabledJHA / Pagination / Previous / Enabled
Pagination previous button - disabledJHA / Pagination / Previous / Disabled
Pagination page button - activeJHA / Pagination / Page / Active
Pagination page button - inactiveJHA / Pagination / Page / Inactive
Pagination next button - enabledJHA / Pagination / Next / Enabled
Pagination next button - disabledJHA / Pagination / Next / Disabled

If you want to show an example of pagination buttons in an artboard, add an appropriate combination of Previous, page number, and Next buttons:

  • If you’re showing the first page button as active, then the Previous button is disabled but all other buttons are enabled.
  • If you’re showing a “middle” page as active, then all buttons are enabled.
  • If you’re showing the last page button as active, then the Next button is disabled but all other buttons are enabled.
  • Only show one of the page buttons as active.

Support options
Have questions on this topic?
Join the Responsive UI team in Microsoft Teams to connect with the community.
See something in this page that needs to change?
Send us feedback on this page.
Last updated Wed Jun 14 2023