当前位置:网站首页>table中同一列中合并相同项
table中同一列中合并相同项
2022-07-29 05:12:00 【喵酱睡着了】
实现效果
实现方法:
1.使用table中提供的合并方法spanMethod
spanMethod({
row, column, rowIndex, columnIndex}) {
if (column.property === 'materielName') {
return {
rowspan: this.mergeObj[column.property][rowIndex],
colspan: 1
}
} else {
return {
rowspan: 1, colspan: 1 }
}
},
2.计算合并项的数目
getMergeObj (list) {
this.mergeObj = {
}
let mack = 0
for (let key in list[0]) {
this.mergeObj[key] = []
mack = 0
list.forEach((item, index) => {
if (index === 0) {
this.mergeObj[key].push(1)
} else {
if (item[key] === list[index - 1][key] && item[key]) {
this.mergeObj[key][mack] += 1
this.mergeObj[key].push(0)
} else {
mack = index
this.mergeObj[key].push(1)
}
}
})
}
}
}
3.渲染table数据后进行处理使用getMergeObj方法
this.getMergeObj(this.tableData)
边栏推荐
猜你喜欢
shell基本操作(上)
牛客网编程题—【WY22 Fibonacci数列】和【替换空格】详解
uniapp组件之tab选项卡滑动切换
B - identify floating point constant problems
Clickhouse learning (VII) table query optimization
Together with digital people, digital space and XR platform, Alibaba cloud and its partners jointly build a "new vision"
ClickHouse学习(十一)clickhouseAPI操作
ClickHouse学习(六)语法优化
Playwright实战案例之爬取js加密数据
省市区三级联动(简单又完美)
随机推荐
With cloud simulation platform, Shichuang technology supports the upgrading of "China smart manufacturing"
href与src的区别
Common shortcut keys for Ad
The function of using wechat applet to scan code to log in to the PC web of the system
Occt learning 001 - Introduction
Database operation day 6
Time complexity and space complexity
[C language series] - constants and variables that confuse students
【C语言系列】— 一道递归小题目
抽象类与接口
第三课threejs全景预览房间案例
redis的基本使用
【活动预告】云上数字工厂与中小企业数字化转型创新论坛
[C language series] - realize the exchange of two numbers without creating the third variable
Occt learning 002 - environment construction
【C语言系列】— 字符串+部分转义字符详解+注释小技巧
PyQt5:第一章第1节:使用Qt组件创建一个用户界面-介绍
Preemptive appointment | Alibaba cloud shadowless cloud application online conference appointment opens
利用Poi-tl在word模板表格单元格内一次插入多张图片和多行单元格相同数据自动合并的功能组件
浅谈Servlet