From 351855328d4f0220c4003c3380a3f364a3ff36a2 Mon Sep 17 00:00:00 2001 From: Sergio Rua Date: Fri, 3 Jul 2026 14:52:28 +0100 Subject: [PATCH] fix(cql console): mark pagination counter as partial while server has more rows Tabulator's local pagination counter only ever reflected rows already loaded into the table, so a server-paged SELECT looked "complete" after the first chunk and the page count silently grew on every "Next" click instead of showing the true state up front. Fixes #1082 Signed-off-by: Sergio Rua --- .../connections/events-get-connections.js | 6 +++++ renderer/js/utils/core.js | 22 ++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/renderer/js/events/connections/events-get-connections.js b/renderer/js/events/connections/events-get-connections.js index c90973e7..59b0411e 100644 --- a/renderer/js/events/connections/events-get-connections.js +++ b/renderer/js/events/connections/events-get-connections.js @@ -3440,6 +3440,9 @@ $(document).on('getConnections refreshConnections', function(e, passedData) { }) } catch (e) {} + // Update the pagination counter's partial/complete state for this chunk before it redraws + tableObj.hasMorePending = isOutputWithPaging && !isOutputCompleted + tableObj.blockRedraw() tableObj.clearSort() tableObj.addData(newPage.json, false).then(() => { @@ -3730,6 +3733,9 @@ $(document).on('getConnections refreshConnections', function(e, passedData) { // Hold the created object tabulatorObject = _tabulatorObject + // Flag the pagination counter as partial while the server still has more rows to fetch + tabulatorObject.hasMorePending = isOutputWithPaging && !isOutputCompleted + tabulatorObject.selectorTableInfo = selectorTableInfo let paginator = outputElement.find('div.sub-output-content').find('span.tabulator-paginator') diff --git a/renderer/js/utils/core.js b/renderer/js/utils/core.js index c3f0bc13..470b48f8 100644 --- a/renderer/js/utils/core.js +++ b/renderer/js/utils/core.js @@ -816,7 +816,27 @@ let convertTableToTabulator = (json, container, paginationSize = 100, pagination // selectableRowsRangeMode: 'click', virtualDom: true, paginationSizeSelector: paginationSizeSelectorEnabled ? [5, 10, 20, 40, 60, 80, 100] : false, - paginationCounter: 'rows', + /** + * Custom counter instead of the built-in `rows` preset + * + * The built-in counter only ever knows about rows already loaded into + * the table, so a server-paged query looks "complete" after every + * chunk. `this.table.hasMorePending` is set by the caller (see + * `events-get-connections.js`) whenever the server still has more + * rows to fetch, so the total shown here can be marked as partial + * instead of misrepresented as final. + */ + paginationCounter: function(pageSize, currentRow, currentPage, totalRows, totalPages) { + let hasMorePending = this.table.hasMorePending === true, + lastRow = totalRows > 0 ? Math.min(currentRow + pageSize - 1, totalRows) : 0, + el = document.createElement('span') + + el.textContent = totalRows > 0 ? + `Showing ${currentRow}-${lastRow} of ${totalRows}${hasMorePending ? '+' : ''} rows${hasMorePending ? ' (more available)' : ''}` : + 'No rows' + + return el + }, rowFormatter: function(row) { /** * Format some data in the rows