当前位置:网站首页>table 组件指定列合并行方法
table 组件指定列合并行方法
2022-07-02 06:22:00 【秦时明月之安康】
大多数table组件只提供了一个合并行或者合并列的抽象方法,例如 element ui 组件,
该方法的参数解释及其用法如下,
看得出来,rowspan代表每一行数据实际占用的行数,colspan代表每一行数据实际占用的列数,我们可以基于原始数据封装如下方法,
export const getSpanMethodData = (data = [], columns = [ ]) => {
let mergeColumns = {
} // 用来记住合并列时数据的索引和重复的次数
let pos = {
} // 用来记录需要合并的列每次出现重复时,重复的次数
columns.forEach(p => {
mergeColumns[p] = []
pos[p] = 0
})
for (let i = 0; i < data.length; i++) {
if (i === 0) {
columns.forEach(p => {
mergeColumns[p].push(1)
pos[p] = 0
})
} else {
columns.forEach((p, index) => {
let obj = {
curr: '',
prev: '',
}
for (let j = 0; j <= index; j++) {
obj.curr += JSON.stringify(data[i][columns[j]])
obj.prev += JSON.stringify(data[i - 1][columns[j]])
}
if (obj.curr === obj.prev) {
mergeColumns[p][pos[p]] += 1
mergeColumns[p].push(0)
} else {
mergeColumns[p].push(1)
pos[p] = i
}
})
}
}
return mergeColumns
}
当执行span-method方法的时候,就可以这样写,
handleSpan ({
row, column, rowIndex, columnIndex, }) {
if (columnIndex === 0) {
const _row = this.table.spanArr[column.key][rowIndex]
const _col = _row > 0 ? 1 : 0
return {
rowspan: _row,
colspan: _col,
}
}
},
边栏推荐
- 重载全局和成员new/delete
- No process runs when querying GPU, but the video memory is occupied
- Find the highest value of the current element Z-index of the page
- 压力测试修改解决方案
- 20210306 reprint how to make TextEdit have background pictures
- virtualenv和pipenv安装
- There is no way to drag the win10 desktop icon (you can select it, open it, delete it, create it, etc., but you can't drag it)
- When requesting resttemplate, set the request header, request parameters, and request body.
- js中对于返回Promise对象的语句如何try catch
- sprintf_s的使用方法
猜你喜欢

ctf三计

Uploading attachments using Win32 in Web Automation

VSCODE 安装LATEX环境,参数配置,常见问题解决

20201002 VS 2019 QT5.14 开发的程序打包

Thread hierarchy in CUDA

Redis - cluster data distribution algorithm & hash slot
![Data science [viii]: SVD (I)](/img/cb/7bf066a656d49666985a865c3a1456.png)
Data science [viii]: SVD (I)

AWD学习

Redis——Cluster数据分布算法&哈希槽

Unexpected inconsistency caused by abnormal power failure; Run fsck manually problem resolved
随机推荐
记录一次RDS故障排除--RDS容量徒增
Self cultivation of programmers - Reflection on job hunting
Latex在VSCODE中编译中文,使用中文路径问题解决
20201002 VS 2019 QT5.14 开发的程序打包
默认google浏览器打不开链接(点击超链接没有反应)
Virtualenv and pipenv installation
分布式事务 :可靠消息最终一致性方案
TensorRT的功能
Sentinel rules persist to Nacos
2020-9-23 QT的定时器Qtimer类的使用。
看完有用的blog
Codeforces Round #797 (Div. 3) A—E
Redis - cluster data distribution algorithm & hash slot
Shardingsphere JDBC
The intern left a big hole when he ran away and made two online problems, which made me miserable
unittest.TextTestRunner不生成txt测试报告
Selenium memo: selenium\webdriver\remote\remote_ connection. Py:374: resourcewarning: unclosed < XXXX > solution
CUDA中的Warp Shuffle
Thread hierarchy in CUDA
CUDA中的动态全局内存分配和操作