table合并单元格函数
作者:互联网
// 通用行合并函数(将相同多列数据合并为一行) mergeRowMethod ({ row, _rowIndex, column, visibleData }) { const fields = ['key'] const cellValue = row[column.property] if (cellValue && fields.includes(column.property)) { const prevRow = visibleData[_rowIndex - 1] let nextRow = visibleData[_rowIndex + 1] if (prevRow && prevRow[column.property] === cellValue) { return { rowspan: 0, colspan: 0 } } else { let countRowspan = 1 while (nextRow && nextRow[column.property] === cellValue) { nextRow = visibleData[++countRowspan + _rowIndex] } if (countRowspan > 1) { return { rowspan: countRowspan, colspan: 1 } } } } }
总体思路就是上一行某个字段数据的与下一行对比是否相等
半年来天天加班到半夜,都没有更新博客了,哎!加油 加油!!!!!
标签:函数,column,单元格,visibleData,countRowspan,rowIndex,nextRow,table,property 来源: https://www.cnblogs.com/maomao93/p/15466587.html