当前位置:网站首页>Merge the same items in the same column in table
Merge the same items in the same column in table
2022-07-29 05:38:00 【Meow sauce fell asleep】
Realization effect
Implementation method :
1. Use table The consolidation method provided in 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. Calculate the number of merged items
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. Rendering table Data processing and use getMergeObj Method
this.getMergeObj(this.tableData)
边栏推荐
猜你喜欢
HCIA-R&S自用笔记(27)综合实验
eggjs 创建应用知识点
Introduction to C language array to proficiency (array elaboration)
Clickhouse learning (VI) grammar optimization
解决表单校验提示信息不消失问题以及赋值不生效问题
Clickhouse learning (IV) SQL operation
shell基本操作(下)
Day 2
About local variables
Provincial and urban three-level linkage (simple and perfect)
随机推荐
微信小程序-组件传参,状态管理
uniapp之常用提示弹框
Day 5
One dimensional array exercise
paddle. Fluid constant calculation error 'nonetype' object has no attribute 'get_ fetch_ list‘
Day 1
利用Poi-tl在word模板表格单元格内一次插入多张图片和多行单元格相同数据自动合并的功能组件
Playwright实战案例之爬取js加密数据
[event preview] cloud digital factory and digital transformation and innovation forum for small and medium-sized enterprises
【无标题】
Day 3
字符类型转换
【剑指offer】— 详解库函数atoi以及模拟实现atoi函数
Day 3
实现简单的数据库查询(不完整)
Clickhouse learning (IV) SQL operation
Detailed explanation of exit interrupt
用threejs 技术做游戏跑酷
Li Kou 994: rotten orange (BFS)
C language n queen problem