Element UI table realizes drop-down filtering function

Element UI table realizes drop-down filtering function

This article example shares the specific code for implementing drop-down filtering in the element UI table for your reference. The specific content is as follows

1. In default-sort, prop passes in the field to be sorted (data returned by the interface or defined by yourself), and order represents the sorting, and descending order is used here
2. In the filters object, text represents the filter text displayed on the page, and value represents the value used for filtering. In the method, filterHandler is used
3. Column key. If you need to use the filter-change event, this attribute is required to identify which column is the filter condition (bound to the field to be sorted in the interface)
4. Whether the data filtering options are multiple selections (multiple means whether to query multiple items)
5. filter-methods: The method used for data filtering. If it is a multiple-select filter item, it will be executed multiple times for each data, and any one that returns true will be displayed. Parameters are value, row, column

<template>
<el-table
        :data="tableData"
        style="width: 100%"
        empty-text="No data yet"
        ref="filterTable"
      >
        <el-table-column
          prop="deviceType"
          label="Device Type"
          show-overflow-tooltip
          column-key="deviceType"
          :filters="[
            { text: 'Weather equipment', value: 1 },
            { text: 'Emotional equipment', value: 0 },
          ]"
          :filter-method="filterHandler"
          :filter-multiple="true"
        >
          <template slot-scope="scope">
            <span v-if="scope.row.deviceType == 1">Weather monitoring equipment</span>
            <span v-if="scope.row.deviceType == 0">Collapse monitoring equipment</span>
            <span></span>
          </template>
        </el-table-column>
      </el-table>
</template>

methods: {
// Header filtering event filterHandler(value, row, column) {
      const property = column["property"];
      return row[property] === value;
    }
     }

Data Types

Page Effects

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • How to set the default value of the select drop-down list in element-ui
  • A brief discussion on the problem of selecting values ​​in the Select drop-down box in Vue Element
  • Solve the problem that the click event of the drop-down menu sub-option in element-ui is not triggered
  • Solution to the problem that the element ui select drop-down box does not echo data
  • The table in vue+Element is editable (select drop-down box)
  • vue+element builds a small summary of the background el-dropdown drop-down function
  • Detailed explanation of element-ui setting drop-down selection to switch required and non-required fields
  • Solve the problem that the default value cannot be deleted when using the drop-down multiple-select box el-select in element-ui
  • How to use the Element Dropdown drop-down menu
  • Vue+Element UI tree control integrates drop-down function menu (tree + dropdown +input)

<<:  A permanent solution to MYSQL's inability to recognize Chinese

>>:  Add ico mirror code to html (favicon.ico is placed in the root directory)

Recommend

Vue implements a simple timer component

When doing a project, it is inevitable to encount...

Analysis and solution of MySQL connection throwing Authentication Failed error

[Problem description] On the application side, th...

React ref usage examples

Table of contents What is ref How to use ref Plac...

XHTML tags that are easily confused by the location of the use

<br />We have always emphasized semantics in...

HTML fixed title column, title header table specific implementation code

Copy code The code is as follows: <!DOCTYPE ht...

Detailed explanation of how to use awk in Linux

Before learning awk, we should have learned sed, ...

How to use sed command to efficiently delete specific lines of a file

Preface Normally, if we want to delete certain li...

Ten important questions for learning the basics of Javascript

Table of contents 1. What is Javascript? 2. What ...

Detailed steps to install MySQL 5.6 X64 version under Linux

environment: 1. CentOS6.5 X64 2.mysql-5.6.34-linu...

HTML table markup tutorial (10): cell padding attribute CELLPADDING

Cell padding is the distance between the cell con...

Detailed example of creating and deleting tables in MySQL

The table creation command requires: The name of...

MySQL column to row conversion tips (share)

Preface: Because many business tables use design ...

Analysis of the principle and usage of MySQL custom functions

This article uses examples to illustrate the prin...