I need to automatically navigate through the pages when the maximum rows number per page is reached.
I have a dataTable and an array that are the records. I added two items into my array and defined the property [rows] as 1.
.html
<p-dataTable #dt [value]="cars" [rows]="1" [paginator]="true"></p-dataTable>
.ts
this.cars.push(new Car("A", "B", "C", "D"));
this.cars.push(new Car("E", "F", "G", "H"));
Also, did the following code when adding a new car when clicking on a button:
.ts
@ViewChild('dt') data: DataTable;
// before this line is all the logic to add the car in the list
if ((this.cars.length - 1) % this.data.rows === 0) {
this.data.paginate();
}
When the first row of a new page is added, it executes the paginate but nothing happens.
What can I do?