Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 42 additions & 1 deletion src/components/Table.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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;
},
Expand Down Expand Up @@ -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<pageEnd; i++){
if (this.groupOptions.enabled) {
paginatedRows.push(this.processedRows[i]);
}
paginatedRows.push(...this.processedRows[i].children);
}
}
else if(this.paginate) {

// 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
Expand Down