if a table looks like the figure above, the subtotal is calculated by yourself. Title 1, title 2 can be sorted by clicking, but the sorting should be kept subtotal, and the total position remains the same
I have tried several methods
- tableData push subtotals and totals, but this point sort sorts subtotals and totals together
<el-table
:data="tableData"
- uses summary-method, but this seems to add only one array, not subtotals and totals. Clicking sorting in this method does not sort subtotals and totals together
<el-table
show-summary
:summary-method="summaryMethod"
:data="tableData"
- tableData push the subtotals and totals, drop the subtotals and totals when you click, and then enter them in push, but still sort them
<el-table
:data="tableData"
border
@sort-change="handleSortChange"
handleSortChange (val) {
setTimeout(() => {
let l = this.tableData.findIndex(items => items.regType === "")
let c = this.tableData.findIndex(items => items.regType === "")
let lobj = {}
let cobj = {}
if (l > -1) {
lobj = {...this.tableData[l]}
this.tableData.splice(l, 1)
}
if (c > -1) {
cobj = {...this.tableData[c]}
this.tableData.splice(c, 1)
}
if (Object.keys(lobj).length > 0) {
this.tableData.push(lobj)
}
if (Object.keys(cobj).length > 0) {
this.tableData.push(cobj)
}
}, 0)
},
- : sort-method= "sortMethod" is estimated to be the same
- uses slot= "append", but what is added is not added after table tbody, at least 2.x is not allowed. 1.X can indeed be kept consistent with the table, and you can click to sort but not include subtotals and totals
do you have any other methods?