Paginator length property set to length of table dataSource.data.length on pageEvent of paginator
See original GitHub issueBug, feature request, or proposal:
Bug
What is the expected behavior?
It should not update to length of data of dataSource
What is the current behavior?
Paginator length property is set to length to dataSource.data.length on pageEvent
Which versions of Angular, Material, OS, TypeScript, browsers are affected?
“@angular/animations”: “5.0.0”, “@angular/cdk”: “5.0.0”, “@angular/common”: “5.0.0”, “@angular/compiler”: “5.0.0”, “@angular/core”: “5.0.0”, “@angular/forms”: “5.0.0”, “@angular/http”: “5.0.0”, “@angular/material”: “5.0.0”, “@angular/platform-browser”: “5.0.0”,
Is there anything else we should know?
This is how i update or set the length for paginator
if(this.totalLength === 0){
this.totalLength = data.total;
}
<mat-paginator #paginator [length]="totalLength"
[pageSize]="limit"
[pageSizeOptions]="pageLimit"
(page)="changePage($event)">
</mat-paginator>`
limit:number = 10;
skip:number = 0;
totalLength:number = 0;
pageIndex : number = 0;
pageLimit:number[] = [5, 10] ;
changePage(event){
console.log(event)
if(this.totalLength > this.dataSource.data.length){
if(this.pageIndex < event.pageIndex){
// next page
this.skip = this.skip + this.limit;
this.getComplains(true);
}
}
}
Issue Analytics
- State:
- Created 5 years ago
- Reactions:5
- Comments:21 (5 by maintainers)
Top Results From Across the Web
mat-paginator length is not working.Not able to set it
dataSource.paginator = this.paginator; this.dataSource.sort = this.sort;. Solution: Initialize these lines only once either by placing some ...
Read more >Angular Material MatPaginator - ConcretePage.com
The properties of MatPaginator are 'color', 'disabled', ... The length sets the total number of items that are being paginated.
Read more >Paginator | Angular Material
Change event object that is emitted when the user selects a different page size or navigates to another page. Properties. Name, Description. length:...
Read more >mat-paginator length is not working.Not able ... - Google Groups
I am trying to call API on the click of pagination. Initially, I had set the length statically and it was working fine....
Read more >Paginator Length Increase On Page Event Angular Material 2
Paginator length property is set to length to dataSource.data.length on Which ... Angular Material Data Table Paginator getting data from datasource on page ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@andrewseguin What i find is that , on start or you can say when i bind data to table data source. I also set paginator length property to total length return from http call *( if total length is 0 )
Now on page event that’s to next page the total length property is having still same value as it’s was on first binding. but length property of paginator vary.
What i understand from this ( https://material.angular.io/components/table/overview#pagination )
the above apply to data which is static or all loaded once( via http call ), but if we want to load data on page event then, this below would apply
So i removed this line
And now it’s working as expected.
So if data source is not dynamically changing or loaded all at once then we can simply provide the MatPaginator to your data source Or else we don’t need to.
Thank @narendrasinghrathore , I have same issue and remove this line
this.dataSource.paginator = this.paginator;
help me resolved it.