tochoromero / aurelia-table

Simple functional data table for Aurelia
https://tochoromero.github.com/aurelia-table
MIT License
67 stars 25 forks source link

Display indexes of items on current page #39

Closed danielyewright closed 7 years ago

danielyewright commented 7 years ago

Is there a way to display the indexes of items on the current page?

For example, displaying Showing 1-10 of 100 and when navigating to the next page display Showing 11-20 of 100, and so on.

tochoromero commented 7 years ago

Yes, you have access to 3 variables that you can use to do the math: currentPage, pageSize and totalItems. When you setup the table you provide this variables like this:

aurelia-table="data.bind: users; display-data.bind: $displayData;
        current-page.bind: currentPage; 
        page-size.bind: pageSize; 
        total-items.bind: totalItems;"

This properties get updated as you navigate the table so just create a getter function that retturns the String with the pagination info and use those properties to calculate it.