zoukankan      html  css  js  c++  java
  • element ui 表格合并方法

    // 合并
        objectSpanMethod({ row, column, rowIndex, columnIndex }) {
          let $rowIndex = rowIndex;
          let fields = ["rectificationNo"]; //需要合并的字段
          let cellValue = row[column.property];
          let data = this.tableData; // 表格的所有数据,
          if (cellValue && fields.includes(column.property)) {
            let prevRow = data[$rowIndex - 1];
            let nextRow = data[$rowIndex + 1];
            if (prevRow && prevRow[column.property] === cellValue) {
              return { rowspan: 0, colspan: 0 };
            } else {
              let countRowspan = 1;
              while (nextRow && nextRow[column.property] === cellValue) {
                nextRow = data[++countRowspan + $rowIndex];
              }
              if (countRowspan > 1) {
                return { rowspan: countRowspan, colspan: 1 };
              }
            }
          }
        },

      在el-table 表格上添加:span-method="objectSpanMethod"

  • 相关阅读:
    简单理解同步与异步
    Python3.x 安装Scrapy框架
    Python命名规范
    python 02/100例
    raw_input与input的区别
    二叉排序树
    串和广义表
    数据结构整理 第一章
    时间复杂度
    Music
  • 原文地址:https://www.cnblogs.com/cyf-1314/p/14918026.html
Copyright © 2011-2022 走看看