# Looking to a way to show the last page of a table

**URL:** <https://forums.knack.com/t/looking-to-a-way-to-show-the-last-page-of-a-table/8363>\
**Category:** Ask Developers\
**Created:** [August 19, 2020, 4:04am UTC](https://forums.knack.com/t/looking-to-a-way-to-show-the-last-page-of-a-table/8363 "2020-08-19T04:04:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![AlagoLowe](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/alagolowe/32/767_2.png) [@AlagoLowe](https://forums.knack.com/u/AlagoLowe)\
**Post date:** [August 19, 2020, 4:04am UTC](https://forums.knack.com/t/looking-to-a-way-to-show-the-last-page-of-a-table/8363/1 "2020-08-19T04:04:34Z")

</div>

Use case: in an accounting ledger (a table), the traditional way to display is to show records chronologically from oldest to newest. And for the convenience, it is good to display the last page (the newest records) when showing the ledger (the table).

I could not find a way in the Knack Developer Docs nor in the community for a javascript.

I also tried the article below, and the result is not as expected (it shows a page with no records):  
[https://support.knack.com/hc/en-us/articles/360030953512-Is-it-possible-to-display-more-than-100-records-at-a-time-on-a-table-list-or-search-view-](https://forums.knack.com/hc/en-us/articles/360030953512-Is-it-possible-to-display-more-than-100-records-at-a-time-on-a-table-list-or-search-view-)

Need your help with a Javascript.

---

<div class="post-metadata">

**Author:** ![AlagoLowe](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/alagolowe/32/767_2.png) [@AlagoLowe](https://forums.knack.com/u/AlagoLowe)\
**Post date:** [August 22, 2020, 2:42am UTC](https://forums.knack.com/t/looking-to-a-way-to-show-the-last-page-of-a-table/8363/2 "2020-08-22T02:42:48Z")

</div>

The above javascript code misses the last line. Here is the revised version:

$(document).on('knack-view-render.view\_xxx', function(event, view, data) {

//Only position the page if no previous filtering applied.   
if (location.href.indexOf('?') == -1) {

&nbsp; &nbsp;var totalRecords = view.pagination\_meta.total\_entries;  
&nbsp; &nbsp;var recsPage = view.pagination\_meta.rows\_per\_page;  
&nbsp; &nbsp;var lastPage = Math.trunc((totalRecords - 1) / recsPage) + 1;

&nbsp; &nbsp;location.hash = location.hash + "?" + view.key + "\_page=" + lastPage;  
}

});

&nbsp;

---

<div class="post-metadata">

**Author:** ![AlagoLowe](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/alagolowe/32/767_2.png) [@AlagoLowe](https://forums.knack.com/u/AlagoLowe)\
**Post date:** [August 21, 2020, 11:36am UTC](https://forums.knack.com/t/looking-to-a-way-to-show-the-last-page-of-a-table/8363/3 "2020-08-21T11:36:18Z")

</div>

Hi Tony, thank you very much. It works, and this is such a smart solution.
