Open In App

Angular PrimeNG Paginator Rows Per Page

Last Updated : 14 Nov, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

Angular PrimeNG is an open-source framework with a rich set of native Angular UI components that are used for great styling and this framework is used to make responsive websites with very much ease. In this article, we will learn how to use the Paginator Rows Per Page in Angular PrimeNG. We will also learn about the properties, events & styling along with their syntaxes that will be used in the code.

The Paginator Component is used to display content in paged format. If rowsPerPageOptions is defined as an array of possible values, the user can select a different value from the dropdown to modify the number of rows per page.

Syntax:

<p-paginator
     [rows]="..."
     [totalRecords]="..."
     [rowsPerPageOptions]="..."
     pageLinkSize="...">
</p-paginator>

 

Angular PrimeNG Paginator Rows Per Page properties:

  • totalRecords: It is the total number of total records pages to be shown. It is of number datatype, the default value is 0.
  • rows: It is the data count to display per page. It is of number datatype, the default value is 0.
  • rowsPerPageOptions: It is the array of integer/object values to display inside the rows per page dropdown. It is of array data type, the default value is null.
  • pageLinkSize: It sets the number of page links to display. It is of number datatype, the default value is 5.

Creating Angular application & module installation:

Step 1: Create an Angular application using the following command.

ng new appname

Step 2: After creating your project folder i.e. appname, move to it using the following command.

cd appname

Step 3: Install PrimeNG in your given directory.

npm install primeng --save
npm install primeicons --save

Project Structure: It will look like the following:

 

  • Steps to run the application: Run the below command to see the output:
ng serve --open

Example 1: Below is the example that illustrates the use of the Angular PrimeNG Paginator Rows Per Page.

  • app.component.html:

HTML




<h1 style="color: green">GeeksforGeeks</h1>
<h5>Angular PrimeNG Paginator Rows Per Page</h5>
  
<p-paginator 
    [rows]="3" 
    [totalRecords]="50" 
    [rowsPerPageOptions]="[5,10,15]"
    pageLinkSize="4">
</p-paginator>


  • app.component.ts:

Javascript




import { Component } from '@angular/core';
  
@Component({
    selector: 'app-root',
    templateUrl: './app.component.html',
})
  
export class AppComponent {}


  • app.module.ts:

Javascript




import { NgModule } from '@angular/core';
import { BrowserModule } 
    from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';
import { BrowserAnimationsModule } 
    from '@angular/platform-browser/animations';
import { AppComponent } from './app.component';
import { PaginatorModule } from 'primeng/paginator';
  
@NgModule({
    imports: [
        BrowserModule,
        BrowserAnimationsModule,
        PaginatorModule,
        FormsModule,
    ],
    declarations: [AppComponent],
    bootstrap: [AppComponent],
})
  
export class AppModule {}


Output:

 

Example 2: Below is another example that illustrates the use of the Angular PrimeNG Paginator Rows Per Page.

  • app.component.html:

HTML




<h1 style="color: green">GeeksforGeeks</h1>
<h5>Angular PrimeNG Paginator Rows Per Page</h5>
  
<p-paginator 
    [rows]="2" 
    [totalRecords]="100" 
    [rowsPerPageOptions]="[10,20,30]"
    pageLinkSize="3">
</p-paginator>


  • app.component.ts:

Javascript




import { Component } from '@angular/core';
  
@Component({
    selector: 'app-root',
    templateUrl: './app.component.html',
})
  
export class AppComponent {}


  • app.module.ts:

Javascript




import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';
import { BrowserAnimationsModule } 
    from '@angular/platform-browser/animations';
import { AppComponent } from './app.component';
import { PaginatorModule } from 'primeng/paginator';
  
@NgModule({
    imports: [
        BrowserModule,
        BrowserAnimationsModule,
        PaginatorModule,
        FormsModule,
    ],
    declarations: [AppComponent],
    bootstrap: [AppComponent],
})
  
export class AppModule {}


Output:

 

Reference: https://primefaces.org/primeng/paginator



Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads