How to eliminate the problem of non-sorting of rows in element-ui2 table sorting

clipboard.png
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

  1. tableData push subtotals and totals, but this point sort sorts subtotals and totals together
<el-table
        :data="tableData"
  1. 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"
  1. 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)
    },
  1. : sort-method= "sortMethod" is estimated to be the same
  2. 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?


sortable is set to 'custom'

listen to the sort-change event of Table and sort the tableData according to the parameters of the event

custom will not call the sorting method of el-table itself

Menu