美文网首页
elementui 合并行和列

elementui 合并行和列

作者: Augenstern___ | 来源:发表于2020-10-16 14:55 被阅读0次
    //表格合同方法 --- 此处只合并了第一列
    objectSpanMethod({ row, column, rowIndex, columnIndex }){
        if (columnIndex === 0) {
          const _row = this.spanArr[rowIndex];
          const _col = _row > 0 ? 1 : 0;
          return {
            rowspan: _row,
            colspan: _col
          };
        }
    
      },
    
    //筛出行里面相同的数据的index  并组装进数组--------请求完表格数据后调用一下这个方法
     rowspan() {
        this.tableData.forEach((item, index) => {
          if (index === 0) {
            this.spanArr.push(1);
            this.position = 0;
          } else {
            if (this.tableData[index].name=== this.tableData[index - 1].name) {
              this.spanArr[this.position] += 1;
              this.spanArr.push(0);
            } else {
              this.spanArr.push(1);
              this.position = index;
            }
          }
        });
      },
    

    表格单选

     //  @select="select"   ref="myInventory"
    select(selection, row) {
      this.$refs.myInventory.clearSelection();
      if (selection.length == 0) return;
      row.editable = true; // 选中行可输入
      this.$refs.myInventory.toggleRowSelection(row, true);
    },

    相关文章

      网友评论

          本文标题:elementui 合并行和列

          本文链接:https://www.haomeiwen.com/subject/kivzpktx.html