The style problem of element-ui table multi-column sorting

problem description

element table sorting defaults to single-column sorting, and the style of the column before the corresponding point will be cancelled. What I need now is multi-column sorting (the function is sorted in the background, and the foreground only needs to resend the request after clicking). Click on the sort of one column, and the sorting style of the other column can be retained (it is observed that classname controls the display of ascending and descending)

the environmental background in which the problem occurs

table ,

clipboard.png

Jun.28,2022

 sort-change   header-cell-class-name  
<el-table @sort-change="handleSortChange" :header-cell-class-name="handleTheadAddClass" class="table">
    //...
</el-table>

data: {
     return {
         curThead: ''
     }
}
   
handleTheadAddClass({row, column, rowIndex, columnIndex}){
    //  
    if( column.prop == this.curThead ){
       return 'active-thead'
    }
},
handleSortChange({ column, prop, order }){
    console.log( column, prop, order )
    //
    this.curThead = prop
}

clipboard.png






1.
image.png
2.
image.png
3.
image.png
4.
image.png
5.
image.png
6.
image.png



ElementUI 2.x table 3.0

clipboard.png

:https://github.com/ElemeFE/element/issues/14398


image.png
image.png
@ sort-change collocation: header-cell-class-name is OK. The code is as follows:
< el-table

:data="tableData"
style="width: 100%"
@sort-change="handleSortChange"
:header-cell-class-name="handleHeaderCellClass"
>

handleHeaderCellClass ({row, column, rowIndex, columnIndex}) {

    console.log('row',row ,'column',column);
     this.orderArray.forEach(element => {
        if (column.property===element.prop) {
          column.order=element.order
        }
      });
  },
  handleSortChange( {column, prop, order} ){
    console.log('column',column, 'prop',prop, 'order',order);
    //ordernull
    if (order) {
      //orderascendingdescending 
      // 1orderArray,2orderArray
      let flagIsHave=false
      this.orderArray.forEach(element => {
        if (element.prop === prop) {
          element.order=order
          flagIsHave=true
        }
      });
      if (!flagIsHave) {
        this.orderArray.push({
          prop:prop,
          order:order
        })
      }
    }else{
      //ordernullorderArray
      let orderIndex=0
       this.orderArray.forEach((element,index) => {
        if (element.prop === prop) {
          orderIndex=index
        }
      });
        this.orderArray.splice(orderIndex,1)
    }
  },
Menu