当前位置:网站首页>Vxe Table/Grid 单元格分组合并
Vxe Table/Grid 单元格分组合并
2022-07-28 00:23:00 【Teln_小凯】
要合并的列
['htbm','htmc','hetd','hetdws','yjs']
一般的合并,不带逻辑,直接就把各自列对应的相同名字的列合并了,如下所示,不是合同的数据,值一样,直接给合并了

加上逻辑区分后的合并,会依次判断前面的字段一致后才合并后面的字段,效果图如下:

实现思路:
1、配置要合并的字段
:mergeFields="['htbm','htmc','hetd','hetdws','yjs']"2、实现vxe table或者grid的合并方法
:span-method="mergeRowMethod"3、具体mergeRowMethod的实现方法如下
// 通用行合并函数(将相同多列数据合并为一行)
mergeRowMethod({ row, _rowIndex, column, visibleData }) {
const fields = this.mergeFields;
if (fields.length == 0) {
return;
}
const cellValue = row[column.property];
if (
cellValue != undefined &&
cellValue != null &&
fields.includes(column.property)
) {
const prevRow = visibleData[_rowIndex - 1];
let nextRow = visibleData[_rowIndex + 1];
//if (prevRow && prevRow[column.property] === cellValue) {
if (prevRow && this.checkMergeFields(row, prevRow, column.property)) {
return { rowspan: 0, colspan: 0 };
} else {
let countRowspan = 1;
//while (nextRow && nextRow[column.property] === cellValue) {
while (nextRow && this.checkMergeFields(row, nextRow, column.property)) {
nextRow = visibleData[++countRowspan + _rowIndex];
}
if (countRowspan > 1) {
return { rowspan: countRowspan, colspan: 1 };
}
}
}
},
//循环判断前面的列,如果值不一样的话就不合并
checkMergeFields(row, nextRow, property) {
var ret = true;
for (var i = 0; i < this.mergeFields.length; i++) {
var field = this.mergeFields[i];
if (nextRow[field] != row[field]) {
ret = false;
break;
}
if (field == property) {
break;
}
}
return ret;
},边栏推荐
- Use of recursion: 1. Convert the tiled array to a tree 2. Convert the tree to a tiled array
- Gbase 8C transaction ID and snapshot (IV)
- Load balancing SLB
- Process data and change the name of data
- How tormenting are weekly and monthly reports? Universal report template recommended collection! (template attached)
- JS what situations can't use json Parse, json.stringify deep copy and a better deep copy method
- GBase 8c 通用文件访问函数
- GBase 8c 注释信息函数
- 小散量化炒股记|量化系统中数据是源头,教你搭建一款普适的数据源框架
- Forget the root password
猜你喜欢

QGIS制图:矢量数据制图流程及导出

Digital economy is the core of future economic development

Packet capturing wizard netcapture app packet capturing tutorial "complete"

物企大变局时代,SRM供应商采购系统助力企业打造物业采购数字化标杆

【taichi】在太极中画出规整的网格

Linux Installation mysql8.0.29 detailed tutorial

Flink's real-time data analysis practice in iFLYTEK AI marketing business

IIC read / write eefprom

N32L43x Flash读\写\擦除操作总结

以“数字化渠道”撬动家用电器消费蓝海,经销商在线系统让企业生意更进一步
随机推荐
HyperMesh circular array - plug in
Thinking about some things
Gbase 8C transaction ID and snapshot (VI)
HCIP第十二天笔记
基于 Flink CDC 实现海量数据的实时同步和转换
写给去不图床用户的一封信
BGP federal experiment
Process data and change the name of data
GBase 8c 事务ID和快照(五)
Interviewer: are you sure redis is a single threaded process?
Data security and privacy computing summit - provable security: Learning
JS数字精度丢失的原因及解决方案
Unity universal red dot system
[Taichi] draw a regular grid in Tai Chi
N32l43x FLASH read \ write \ erase operation summary
Collection / container
Custom type: structure, enumeration, union
day7
Comparison between hardware SPI and software analog SPI rate
Load balancing SLB