Компоненты PrimeNG
Paginator

Пагинация

PrimeNG/Paginator (opens in a new tab)

Paginator - это универсальный компонент для отображения содержимого в формате страницы.

С чего начать

Подключите модуль

import { PaginatorModule } from 'primeng/paginator';

Встройте компонент с помощью тэга p-paginator.

Basic

Свойства

NameTypeDefaultDescription
totalRecordsnumber0Number of total records.
rowsnumber0Data count to display per page.
firstnumber0Zero-relative number of the first row to be displayed.
pageLinkSizenumber5Number of page links to display.
rowsPerPageOptionsarraynullArray of integer/object values to display inside rows per page dropdown. A object that have 'showAll' key can be added to it to show all data. Exp; [10,20,30,showAll:'All']
stylestringnullInline style of the component.
styleClassstringnullStyle class of the component.
alwaysShowbooleantrueWhether to show it even there is only one page.
showFirstLastIconbooleantrueWhen enabled, icons are displayed on paginator to go first and last page.
templateLeftTemplateRefnullTemplate instance to inject into the left side of the paginator.
templateRightTemplateRefnullTemplate instance to inject into the right side of the paginator.
dropdownItemTemplateTemplateRefnullTemplate instance to inject into the dropdown item inside in the paginator.
dropdownAppendToanynullTarget element to attach the dropdown overlay, valid values are "body" or a local ng-template variable of another element (note: use binding with brackets for template variables, e.g. [appendTo]="mydiv" for a div element having #mydiv as variable name).
dropdownScrollHeightstring200pxDropdown height of the viewport in pixels, a scrollbar is defined if height of list exceeds this value.
currentPageReportTemplatestring(currentPage of totalPages)Template of the current page report element. Available placeholders are currentPage,totalPages,rows,first,last and totalRecords
showCurrentPageReportbooleanfalseWhether to display current page report.
showJumpToPageDropdownbooleanfalseWhether to display a dropdown to navigate to any page.
showJumpToPageInputbooleanfalseWhether to display a input to navigate to any page.
showPageLinksbooleantrueWhether to show page links.

События

NameParametersDescription
onPageChangeevent.first: Index of first record<br>event.rows: Number of rows to display in new page<br>event.page: Index of the new page<br>event.pageCount: Total number of pages<br>Callback to invoke when page changes, the event object contains information about the new state.

Стилизация

NameElement
p-paginatorContainer element.
p-paginator-firstFirst page element.
p-paginator-prevPrevious page element.
p-paginator-pagesContainer of page links.
p-paginator-pageA page link.
p-paginator-nextNext page element.
p-paginator-lastLast page element.
p-paginator-rpp-optionsRows per page dropdown.
p-paginator-page-optionsJump to per page dropdown.