Element Table table component multi-field (multi-column) sorting method

Element Table table component multi-field (multi-column) sorting method

need:

To sort multiple columns in the element table, click on the date sort, then click on the name sort, and pass the two sort fields to the backend for sorting.

Problems encountered:

The Table component of element only supports single-column sorting. When you click on the sorting of another column, the previous sorting will be automatically canceled. I searched online for methods and found this article that proposed using :header-cell-class-name and @sort-change to handle the style problem of multi-column sorting. I tried for a long time and found that the sort-change event would return null when canceling the sort, so I couldn't locate which column canceled the sort. In short, the problem could not be solved by relying on element-table events.

solve:

By customizing the header, paste the two small icons directly into the header. Then bind the click sorting events respectively. In this way, we can get both the sorting status (ascending, descending, unsorted) and the sorted column name. At this point, the readers should understand that the specific code is in the intranet and it is not easy to paste it out. If you have any questions, please comment and I will try my best to answer~

This is the end of this article about the multi-field (multi-column) sorting method of the element Table component. For more relevant content on multi-field sorting of element Table, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Solve the problem of mixed sorting of numbers, letters and Chinese in table in vue elementUI
  • Elementui table component + sortablejs to implement row drag and drop sorting sample code
  • Vue element table table request background sorting method
  • Use jQuery.sortElements to sort the table

<<:  How to connect idea to docker to achieve one-click deployment

>>:  Undo log in MySQL

Recommend

Detailed explanation of routes configuration of Vue-Router

Table of contents introduce Object attributes in ...

mysql5.7 installation and configuration tutorial under Centos7.3

This article shares the MySQL 5.7 installation an...

Summary of Vue first screen performance optimization component knowledge points

Vue first screen performance optimization compone...

Complete steps to install mysql5.7 on Mac (with pictures and text)

I recently used a Mac system and was preparing to...

Problems and solutions of using jsx syntax in React-vscode

Problem Description After installing the plugin E...

Detailed explanation of MySQL sql99 syntax inner join and non-equivalent join

#Case: Query employee salary levels SELECT salary...

Detailed explanation of mixins in Vue.js

Mixins provide distributed reusable functionality...

Docker installs the official Redis image and enables password authentication

Reference: Docker official redis documentation 1....

This article will help you understand the life cycle in Vue

Table of contents 1. beforeCreate & created 2...

Introduction to the deletion process of B-tree

In the previous article https://www.jb51.net/arti...

How to use Vue3 mixin

Table of contents 1. How to use mixin? 2. Notes o...

Sample code for converting video using ffmpeg command line

Before starting the main text of this article, yo...

Vue2 cube-ui time selector detailed explanation

Table of contents Preface 1. Demand and Effect ne...

Detailed tutorial for installing MySQL on Linux

MySQL downloads for all platforms are available a...

In-depth interpretation of /etc/fstab file in Linux system

Preface [root@localhost ~]# cat /etc/fstab # # /e...