From d8cf5500302c666162b399337848124f52ce42d7 Mon Sep 17 00:00:00 2001 From: Harsh Saxena Date: Thu, 25 Sep 2025 11:39:53 +0530 Subject: [PATCH] Fix: Pagination fix for grouped rows --- src/components/Table.vue | 43 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/src/components/Table.vue b/src/components/Table.vue index 9db76153..1dbcdecb 100644 --- a/src/components/Table.vue +++ b/src/components/Table.vue @@ -708,15 +708,27 @@ export default { }, totalRowCount() { const total = this.processedRows.reduce((total, headerRow) => { + if(this.groupOptions.enabled) { + const childrenCount = 1; + return total + childrenCount; + } + else { const childrenCount = headerRow.children ? headerRow.children.length : 0; return total + childrenCount; + } }, 0); return total; }, totalPageRowCount() { const total = this.paginated.reduce((total, headerRow) => { + if(this.groupOptions.enabled) { + const childrenCount = 1; + return total + childrenCount; + } + else { const childrenCount = headerRow.children ? headerRow.children.length : 0; return total + childrenCount; + } }, 0); return total; }, @@ -897,9 +909,38 @@ export default { paginatedRows.push(...childRows.children); }); - if (this.paginate) { + // page start wil remain same for group options enabled or not let pageStart = (this.currentPage - 1) * this.currentPerPage; + // if group options are enabled, pagination will happen differently + if (this.paginate && this.groupOptions.enabled) { + // in case of filtering we might be on a page that is + // not relevant anymore + // also, if setting to all, current page will not be valid + if (pageStart >= this.processedRows.length || this.currentPerPage === -1) { + this.currentPage = 1; + pageStart = 0; + } + + + // calculate page end now + let pageEnd = this.processedRows.length; + + // if the setting is not set to 'all' + if (this.currentPerPage !== -1) { + pageEnd = Math.min(this.currentPage * this.currentPerPage,this.processedRows.length); + } + + paginatedRows = []; + for(let i = pageStart; i