@richard-mortimer said in Pagination for a page:
@craigweb said in Pagination for a page:
Hi Richard
I believe, you do not need your query string function as there is already a component for this. You will need to register you page with the URL of ?page
<ma-state-params on-change="PageStart = $stateParams.page; stateParams = $stateParams" update-
params="updateParams"></ma-state-params>
Here is a help document that explains how to use it with a watchlist:
https://help.infiniteautomation.com/linking-to-dynamic-pages
Thanks for that, the PageStart
variable is read in as what it should be, but seems to be overwritten when I'm reading in the Settings
parameters (no matter where I put it on the page), so even when this is at the bottom of the page:
<ma-state-params on-change="Settings.PageStart = $stateParams.page; stateParams = $stateParams" update-params="updateParams"></ma-state-params>
And this is at the top:
<ma-json-store xid="PageConfigXID" value="Settings"></ma-json-store><!-- page configuration data -->
The value goes from 2
to 0
with this URL: http://mango2:8080/ui/richard-overview-angular?page=2
Any idea how to make the value stick ... ?
Scratch that - I've used two repeats - if the PageStart
value doesn't exists - it displays the page as normal, but if it does exist, it does sends it to the second repeat and uses that value for the calculation of where to start the page. Kinda goes against the DRY prinicipal, but works effectively ....
So, in the first instance:
<div ng-if="!PageStart" class="table" ng-repeat="site in sites.sites | limitTo: Settings.PageSize : Settings.PageStart">
And in the second:
<div ng-if="PageStart" class="table" ng-repeat="site in sites.sites | limitTo: Settings.PageSize : (( PageStart - 1 ) * Settings.PageSize)">
Cheers
Richard