当前位置:网站首页>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;
},边栏推荐
- The petrochemical industry is facing the tide of rising prices, and the digital dealer distribution system platform enables dealers and stores
- day7
- GBase 8c 事务ID和快照(三)
- Gbase 8C recovery control function
- Flink 在 讯飞 AI 营销业务的实时数据分析实践
- GBase 8c 事务ID和快照(六)
- ArcGIS:加载历史遥感影像
- 嵌入式经典通信协议
- BGP联邦实验
- Completely delete MySQL in Linux system
猜你喜欢

unreal ue4.27 switchboard 移植出引擎流程

Custom type: structure, enumeration, union

Packet capturing wizard netcapture app packet capturing tutorial "complete"

BGP federal experiment

Solution of digital commerce cloud supply chain centralized purchase management system: centralized purchase system management mode, digital control of enterprise materials

云原生爱好者周刊:Prometheus 架构演进之路

开源飞控(PX4、ardupilot)

数据安全与隐私计算峰会-可证明安全:学习

Netease cloud copywriting

萤石网络,难当「孤勇者」
随机推荐
Interviewer: are you sure redis is a single threaded process?
GBase 8c 事务ID和快照(四)
萤石网络,难当「孤勇者」
Hcip 13th day notes
js 哪些情况不能用 JSON.parse 、JSON.stringify深拷贝及一个更好的深拷贝方法
[interview: concurrent article 28:volatile] orderliness
Common modules of ros2 launch files
数字经济才是未来经济发展的核心
Custom type: structure, enumeration, union
基于 Flink CDC 实现海量数据的实时同步和转换
Real time synchronization and conversion of massive data based on Flink CDC
GBase 8c 配置设置函数
Forget the root password
N32l43x FLASH read \ write \ erase operation summary
Mark's story
Software testing interview question: what types of software testing are you familiar with?
What devices does devicexplorer OPC server support? This article has listed
Packet capturing wizard netcapture app packet capturing tutorial "complete"
二叉树的遍历和性质
day7