zoukankan      html  css  js  c++  java
  • element ui 表格 合并单元格?

        问题: 将表格中 id相同的数据,某一列合并?

        :span-method="objectSpanMethod"  // talbe 中加入的方法, :span-method是element 进行表单合并的钩子函数。
      objectSpanMethod({ row, column, rowIndex, columnIndex }) {//行 , 列 , 行号 , 列号
          if (columnIndex === 1 || columnIndex === 2 || columnIndex === 3 ) {
            const sameRoutIdList = this.planekingList.filter(i =>  //过滤出id相同的数据
              i.planUnitId === row.planUnitId
            )
            const spanLength = sameRoutIdList.length     //统计 id相同数据的长度
            const firstIndex = this.planekingList.findIndex(i =>  //找打id相同数据的第一个下标
              i.planUnitId === row.planUnitId
            )
            if (spanLength > 1) {  //如果长度大于 1 
              if (rowIndex === firstIndex) {  
                return {
                  rowspan: spanLength,//合并的行数
                  colspan: 1
                }
              } else {
                return {
                  rowspan: 0,
                  colspan: 0
                }
              }
            } else {
              return {
                rowspan: 1,
                colspan: 1
              }
            }
          }
        },

       

         

  • 相关阅读:
    CSS hack
    字符串中常用的方法
    排序算法
    拾遗
    数组类型检测
    数组常用的方法
    go 文件服务器(标准库) 添加关机,睡眠,退出功能
    go cmd 交互 初始化执行某些命令
    go 内网IP及外网IP获取
    go 快排实现
  • 原文地址:https://www.cnblogs.com/javascript9527/p/12699924.html
Copyright © 2011-2022 走看看