fix: 🐛 Extract getTotalRow into a function
This commit is contained in:
parent
96c7b723da
commit
1e20502d09
@ -47,6 +47,13 @@ export default class BodyRenderer {
|
|||||||
renderFooter() {
|
renderFooter() {
|
||||||
if (!this.options.showTotalRow) return;
|
if (!this.options.showTotalRow) return;
|
||||||
|
|
||||||
|
const totalRow = this.getTotalRow();
|
||||||
|
let html = this.rowmanager.getRowHTML(totalRow, { isTotalRow: 1, rowIndex: 'totalRow' });
|
||||||
|
|
||||||
|
this.footer.innerHTML = html;
|
||||||
|
}
|
||||||
|
|
||||||
|
getTotalRow() {
|
||||||
const columns = this.datamanager.getColumns();
|
const columns = this.datamanager.getColumns();
|
||||||
const totalRowTemplate = columns.map(col => {
|
const totalRowTemplate = columns.map(col => {
|
||||||
let content = 0;
|
let content = 0;
|
||||||
@ -60,7 +67,6 @@ export default class BodyRenderer {
|
|||||||
column: col
|
column: col
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
const totalRow = this.visibleRows.reduce((acc, prevRow) => {
|
const totalRow = this.visibleRows.reduce((acc, prevRow) => {
|
||||||
return acc.map((cell, i) => {
|
return acc.map((cell, i) => {
|
||||||
const prevCell = prevRow[i];
|
const prevCell = prevRow[i];
|
||||||
@ -73,10 +79,7 @@ export default class BodyRenderer {
|
|||||||
return Object.assign({}, cell);
|
return Object.assign({}, cell);
|
||||||
});
|
});
|
||||||
}, totalRowTemplate);
|
}, totalRowTemplate);
|
||||||
|
return totalRow;
|
||||||
let html = this.rowmanager.getRowHTML(totalRow, { isTotalRow: 1, rowIndex: 'totalRow' });
|
|
||||||
|
|
||||||
this.footer.innerHTML = html;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
restoreState() {
|
restoreState() {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user