Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

correct implementation of datasource pagination

So at first page it shows the corrrect display

enter image description here


But when I click next page it is displaying , it it displaying 21-20 of , which is wrong.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

enter image description here

enter image description here

#html code that uses the component add passes the prefix text and suffix text

<app-table-paginator-text [dataSource]="dataSource" [prefixText]="'Showing'" [suffixText]="'results'"></app-table-paginator-text>  

#data source html code

<div id="table-paginator-text" class="secondary-text" *ngIf="dataSource.paginator !== undefined">
  {{prefixText}} {{(dataSource.paginator.pageIndex === 0)? 1: (dataSource.paginator.pageSize * dataSource.paginator.pageIndex) + 1 }} - {{this.dataSource.connect().value.length}} of {{dataSource.data.length}} {{suffixText}}      
</div>    

>Solution :

In your data source code, you are correctly offsetting the left-hand number by the pageSize, but the right-hand side is simply the length of the current set. You need to add the offset there, too. I think the following should do it:

(dataSource.paginator.pageSize * dataSource.paginator.pageIndex) + this.dataSource.connect().value.length
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading