Table: improve performance of summary-method (#11521)

pull/11536/head
Jikkai Xiao 2018-06-07 11:37:26 +08:00 committed by 杨奕
parent d1391e325c
commit 2b9be3c0fb
1 changed files with 33 additions and 29 deletions

View File

@ -6,7 +6,10 @@ export default {
mixins: [LayoutObserver],
render(h) {
const sums = [];
let sums = [];
if (this.summaryMethod) {
sums = this.summaryMethod({ columns: this.columns, data: this.store.states.data });
} else {
this.columns.forEach((column, index) => {
if (index === 0) {
sums[index] = this.sumText;
@ -36,6 +39,7 @@ export default {
sums[index] = '';
}
});
}
return (
<table
@ -61,7 +65,7 @@ export default {
class={ [column.id, column.headerAlign, column.className || '', this.isCellHidden(cellIndex, this.columns) ? 'is-hidden' : '', !column.children ? 'is-leaf' : '', column.labelClassName] }>
<div class={ ['cell', column.labelClassName] }>
{
this.summaryMethod ? this.summaryMethod({ columns: this.columns, data: this.store.states.data })[cellIndex] : sums[cellIndex]
sums[cellIndex]
}
</div>
</td>