Primeng: Paginator - 'first' property not working

Created on 17 Jul 2017  路  7Comments  路  Source: primefaces/primeng

I'm submitting a ... (check one with "x")

[x] bug report => Search github for a similar issue or PR before submitting
[ ] feature request => Please check if request is not on the roadmap already https://github.com/primefaces/primeng/wiki/Roadmap
[ ] support request => Please do not submit support request here, instead see http://forum.primefaces.org/viewforum.php?f=35

Plunkr Case (Bug Reports)
Please fork the plunkr below and create a case demonstrating your bug report. Issues without a plunkr have much less possibility to be reviewed.

http://plnkr.co/edit/STNlxNnNWnmNabTzx6jy?p=preview
See app.template.html

Current behavior
<p-paginator> ignores 'first' property to tell that it should render on particular page

Expected behavior
<p-paginator> should be initialized on specified page when 'first' property is used

Minimal reproduction of the problem with instructions
Just see plunker above.

What is the motivation / use case for changing the behavior?
API not working

Please tell us about your environment:
Angular CLI 1.2.0

  • Angular version: 4.2.6

  • PrimeNG version: 4.1.0

  • Browser: [all]

  • Language: [TypeScript 2.3.3]

  • Node (for AoT issues): node --version = 8.1.2

Most helpful comment

@SSTPIERRE2 is working show
https://stackblitz.com/edit/github-gbjzr8?file=src/app/app.component.ts

Attention!!! the variable "first" is not the PAGE is the row, if you have 10 rows on page, row 11 is on site 2

All 7 comments

You need to use [] otherwise Angular interprets values as string, fixing the plunkr;

export class AppComponent {

   first: number = 10;

   reset() {
        this.first = 0;
    }
}
<p-paginator [rows]="10" (onPageChange)="paginate($event)" [(first)]="first" [totalRecords]="120" [rowsPerPageOptions]="[10,20,30]"></p-paginator>


First: ###{{first}}##
<button type="button" (click)="reset()">Reset First</button>

Also note that first is not the page number, page number is Math.floor(this.first / this.rows);

i changed my plunkr

show http://plnkr.co/edit/9dcOEq6J80HoSLU8Iv3X?p=preview

i change the page (example 2)
i click "Reset First" => Page 1 IS open
i change the page (example 2)
i click "Reset First" => Page 1 IS NOT open

Also note that first is not the page number, page number is Math.floor(this.first / this.rows);

and on which way i can open a spezial page number? If i have 10 Pages and i want to open page 2?

The first property still doesn't work.

@SSTPIERRE2 is working show
https://stackblitz.com/edit/github-gbjzr8?file=src/app/app.component.ts

Attention!!! the variable "first" is not the PAGE is the row, if you have 10 rows on page, row 11 is on site 2

@SSTPIERRE2

The first property still doesn't work.

Yeah, I recently needed to use it to solve an issue and indeed it doesn't work, at least for treetable. It might be because I'm using lazy loading. Maybe check that. I solved it by using Viewchild and using the property that way.

p-paginator set first page - worked for me:

Get paginator element
@ViewChild('paginator') paginator: any;

Set paginator page index
this.paginator.changePage(X)

X = number

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Helayxa picture Helayxa  路  3Comments

pchristou picture pchristou  路  3Comments

jisqaqov picture jisqaqov  路  3Comments

mitosandov picture mitosandov  路  3Comments

lilling picture lilling  路  3Comments