当前位置:网站首页>Explanation of El table paging select all function
Explanation of El table paging select all function
2022-06-21 18:42:00 【Crmeb Zhongbang Technology】
Today, I will learn one with you el-table Paged select all function
We were using the el-table Component time , You will definitely use the paging function , Whether it's long list drop-down paging or element-UI Of el-pagination Pagination .
But we are in the process of selecting el-table When , There will be a problem , After clicking to page , The previously selected data is gone , This problem really bothers me for a long time .
In the back, I started to develop for Baidu , Did you find one bug This method is :
stay el-table in , adopt @selection-change=“handleRowSelection” and :row-key=“getRowKeys”,
In the first line , That is, on the column of the multi selection box , add :reserve-selection="true", Go straight to the code , For your reference only .
<template> <div> <el-table ref="table" :data="tableData" size="small" height="100%"row-key=“id” @selection-change="handleSelectChange" @select="handleSelect" > <el-table-column width="50" type="selection" /> <el-table-column type="index" label=" Serial number " width="50"> <template scope="scope"> <span>{{ (pageInfo.pageNo - 1) * pageInfo.pageSize + scope.$index + 1 }}</span> </template> </el-table-column> <el-table-column label=" name 1" /> <el-table-column label=" name 2" /> <el-table-column label=" name 3" /> <el-table-column label=" name 4" /> <el-table-column label=" name 5" /> </el-table> </div></template><script>export default { data() { return { tableData: [], selectedObj: {}, selectedData: [] } }, methods: { getList() { // Where to look up data , Process page selection status this.handleRowSelection(this.tableData) }, handleSelectChange(selection) { // Select all to cancel , Delete all data of the current page if (selection.length === 0) { this.tableData.forEach(item => { delete this.selectedObj[item.id] }) } // Tick data add to selection.forEach(item => { this.selectedObj[item.id] = item }) // Get the data checked in all pages this.selectedData = [] for (const key in this.selectedObj) { this.selectedData.push(this.selectedObj[key]) } }, handleSelect(selection, row) { // When a single check is cancelled , Delete the corresponding attribute if (!selection.some(item => item.id === row.id)) { delete this.selectedObj[row.id] } }, // Process the current list selection status handleRowSelection(data) { data.forEach(item => { if (this.selectedObj[item.id]) { this.$nextTick(() => { this.$refs.table.toggleRowSelection(item) }) } }) } }}</script>The source code attachment has been packaged and uploaded to Baidu cloud , You can download it yourself ~
link : https://pan.baidu.com/s/14G-bpVthImHD4eosZUNSFA?pwd=yu27 Extraction code : yu27Baidu cloud link is unstable , It may fail at any time , Let's keep it tight .
If Baidu cloud link fails , Please leave me a message , When I see it, I will update it in time ~
Open source address
Code cloud address :
http://github.crmeb.net/u/defu
Github Address :
http://github.crmeb.net/u/defu
边栏推荐
猜你喜欢

2022低压电工考试题模拟考试题库及答案

信创环境下缓存服务Redis集群部署

Redis配置与优化

TypeScript类对象的初始化

R语言 bug?报错?关于亚变量0、1 结局outcome,outcome变量经过factor和numeric过程,改变了原始内容?

SVG+Canvas粒子动态效果

Operation of simulation test platform for test questions bank of R1 quick opening pressure vessel operation certificate in 2022

AWS Device Shadow使用
![Leetcode 1108 IP address invalidation [violence] the leetcode path of heroding](/img/c6/d3eb6cee92b1c0848bf3d3b58b8b22.png)
Leetcode 1108 IP address invalidation [violence] the leetcode path of heroding

canvas动态背景文本发光js特效
随机推荐
两种圆点垂直进度样式
Generics of typescript
Disclose the design idea of MVVM framework supporting Baidu search, feed and applet, and San core personnel have made great efforts to build it
让接口自动化测试灵动起来
Can I use line as a product term in the cable industry? Generally not used
Typescript interface
MySQL common interview questions
Vue.js+Node.js全栈开发教程:连接MySQL
Check information on the Internet after the college entrance examination, and pay attention to prevent websites without SSL certificates
2022年R1快开门式压力容器操作操作证考试题库模拟考试平台操作
科普大佬说 | 如何打造自己的AI创造力?
A new generation of stability testing tool fastbot
Gartner 网络研讨会 “九问数字化转型” 会后感
Type checking for typescript
最佳网络数据抓包工具mitmproxy
【微服务|Nacos】快速实现nacos的配置中心功能,并完成配置更新和版本迭代
Redis配置与优化
CANN训练营第二季-开营仪式 | 今晚七点半准时开播,不容错过!
力扣461.汉明距离
AWS device shadow usage