国产精品久久久久aaaa_午夜精品成人一区二区视频_在线观看日韩_欧美日韩精品一区二区三区蜜桃_女人被狂躁后的视频免费_日本成人在线播放

首頁 生活 > 正文

Element Plus el-table 自定義合并行和列


(資料圖片僅供參考)

原文鏈接:Element Plus el-table 自定義合并行和列

前言

目標效果是將表格行數據中某個屬性值相同的項合并到一起,效果如下:

                            
import type { TableColumnCtx } from "element-plus"const tableData = [  { "Available": 0, "Capacity": 0, "Name": "test05", "Status": 0, "StoAlias": "test", "Type": 0, "Used": 0 },  { "Available": 0, "Capacity": 0, "Name": "test01", "Status": 0, "StoAlias": "169.254.218", "Type": 0, "Used": 0 },  { "Available": 0, "Capacity": 0, "Name": "tset03", "Status": 0, "StoAlias": "test", "Type": 1, "Used": 0 },  { "Available": 0, "Capacity": 0, "Name": "test02", "Status": 0, "StoAlias": "test03", "Type": 0, "Used": 0 },  { "Available": 0, "Capacity": 0, "Name": "test06", "Status": 0, "StoAlias": "test03", "Type": 0, "Used": 0 },  { "Available": 0, "Capacity": 0, "Name": "test04", "Status": 0, "StoAlias": "169.254.218", "Type": 0, "Used": 0 },  { "Available": 0, "Capacity": 0, "Name": "test07", "Status": 0, "StoAlias": "169.254.218", "Type": 1, "Used": 0 }]let cellList: any[] = [] // 單元格數組let count: number = 0 // 計數const computeCell = (tableList: any[]) => {  cellList = []  count = 0  for (let i = 0; i < tableList.length; i++) {    if (i === 0) {      // 先設置第一項      cellList.push(1); // 初為1,若下一項和此項相同,就往cellList數組中追加0      count = 0; // 初始計數為0    } else {      if (tableList[i].StoAlias == tableList[i - 1].StoAlias) {        cellList[count] += 1; // 增加計數        cellList.push(0); // 相等就往cellList數組中追加0      } else {        cellList.push(1); // 不等就往cellList數組中追加1        count = i; // 將索引賦值為計數      }    }  }}const sortArray = (x: any, y: any) => {  if (x.StoAlias < y.StoAlias) { return -1 }  else if (x.StoAlias > y.StoAlias) { return 1 }  else { return 0 }}interface SpanMethodProps {  row: StoragePoolItem  column: TableColumnCtx  rowIndex: number  columnIndex: number}const spanMethod = ({  rowIndex,  columnIndex,}: SpanMethodProps) => {    computeCell(tableData.sort(sortArray))    if (columnIndex === 0) {      const fRow = cellList[rowIndex]      const fCol = fRow > 0 ? 1 : 0      return {        rowspan: fRow, // 合并的行數        colspan: fCol // 合并的列數,為0表示不顯示      }    }}

sortArray()此方法根據目標屬性值(StoAlias)排序了。

點擊 傳送門 查看更多關于【el-table 合并行或列】的信息。

關鍵詞:

最近更新

關于本站 管理團隊 版權申明 網站地圖 聯系合作 招聘信息

Copyright © 2005-2023 創投網 - www.pdssy.com.cn All rights reserved
聯系我們:39 60 29 14 [email protected]
皖ICP備2022009963號-3

主站蜘蛛池模板: 色婷婷av久久久久久久 | 亚洲热综合 | 中文字幕在线一区二区三区 | 亚洲欧美日韩精品久久奇米色影视 | 网红和老师啪啪对白清晰 | 国产日韩一区 | 日韩久久综合 | 鲁丝片一区二区三区毛片 | 精品视频二区 | 欧美电影一区 | 欧美日韩在线免费观看 | 精品的一区二区三区 | 青青热在线观看视频精品 | 东京一热本色道久久爱 | 久久91av | 色五月婷婷成人网 | 亚洲欧美日本人成在线观看 | 亚洲三区视频 | 欧美视频亚洲视频 | 国产精品自在线 | 亚洲高清久久 | 视频在线亚洲 | 在线播放亚洲 | 天天干精品 | 91短视频app下载 | 色人阁在线 | 国产精品视频播放 | 日本黄色片一级片 | 精品国产一区三区 | 一级毛片网 | 亚洲精品一二三区-久久 | 亚洲国产精品一区二区第一页 | 女人a级毛片19毛水真多 | 精品九九视频 | 天天拍天天色 | 成熟人妻AV无码专区A片 | 日日射影院 | 亚洲蜜桃AV色情精品成人 | 黄色小视频在线免费看 | 丝袜美腿一区二区三区动态图 | 国产人成激情视频在线观看 |