Skip to content

Commit 705844e

Browse files
authored
Pagination widget update (#1468)
* Update paginated-data.html * Update paginated-data-server-script.js
1 parent 4e720e3 commit 705844e

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

Service Portal Widgets/Paginated Data/paginated-data-server-script.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
data.recordsTable = 'task';
44
data.recordsQuery = ''; // The encoded query to filter records (empty means all records)
55
data.recordsFields = ['number', 'short_description']; // The fields to retrieve for each record
6-
data.recordsPerPage = 10;
6+
data.recordsPerPage = parseInt($sp.getParameter('display')) || 10;
7+
data.userQuery = $sp.getParameter('query');
78

89
// Get pagination parameters
910
data.page_id = $sp.getParameter('id');
@@ -13,6 +14,7 @@
1314
// Count total records
1415
var countGa = new GlideAggregate(data.recordsTable);
1516
countGa.addEncodedQuery(data.recordsQuery);
17+
countGa.addEncodedQuery(data.userQuery);
1618
countGa.addAggregate('COUNT');
1719
countGa.query();
1820
if (countGa.next()) {
@@ -34,6 +36,7 @@
3436
data.records = [];
3537
var recordsGr = new GlideRecord(data.recordsTable);
3638
recordsGr.addEncodedQuery(data.recordsQuery);
39+
recordsGr.addEncodedQuery(data.userQuery);
3740
recordsGr.chooseWindow(data.rowStart, rowEnd);
3841
recordsGr.query();
3942
while (recordsGr.next()) {

Service Portal Widgets/Paginated Data/paginated-data.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<nav aria-label="Page navigation" ng-if="data.count > 0">
88
<ul class="pagination">
99
<li class="page-item">
10-
<a class="page-link" href="?id={{data.page_id}}&page={{data.page-1}}" aria-label="Previous" ng-if="data.page > 1">
10+
<a class="page-link" href="?id={{data.page_id}}&page={{data.page-1}}&display={{data.display}}&query={{data.userQuery}}" aria-label="Previous" ng-if="data.page > 1">
1111
<span aria-hidden="true">&laquo;</span>
1212
<span class="sr-only">Previous</span>
1313
</a>
@@ -16,9 +16,9 @@
1616
<span class="sr-only">Previous</span>
1717
</a>
1818
</li>
19-
<li class="page-item" ng-repeat="page in data.pages track by $index" ng-class="{active: page == data.page}"><a class="page-link" href="?id={{data.page_id}}&page={{page}}" ng-if="page != '...'">{{page}}</a><span ng-if="page == '...'">...</span></li>
19+
<li class="page-item" ng-repeat="page in data.pages track by $index" ng-class="{active: page == data.page}"><a class="page-link" href="?id={{data.page_id}}&page={{page}}&display={{data.display}}&query={{data.userQuery}}" ng-if="page != '...'">{{page}}</a><span ng-if="page == '...'">...</span></li>
2020
<li class="page-item">
21-
<a class="page-link" href="?id={{data.page_id}}&page={{data.page+1}}" aria-label="Next" ng-if="data.page < data.pages[data.pages.length - 1]">
21+
<a class="page-link" href="?id={{data.page_id}}&page={{data.page+1}}&display={{data.display}}&query={{data.userQuery}}" aria-label="Next" ng-if="data.page < data.pages[data.pages.length - 1]">
2222
<span aria-hidden="true">&raquo;</span>
2323
<span class="sr-only">Next</span>
2424
</a>

0 commit comments

Comments
 (0)