国产精品久久久久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

主站蜘蛛池模板: 91精品成人免费国产 | 午夜激情爱爱 | 四虎影院最新网站 | 性国产精品 | 男女xx| 国产精品91在线播放 | 太平公主一级艳史播放高清 | 无码一区二区三区曰本A片 欧美综合激情网 | 国产精品一码二码三码在线 | 国产精品久久久久久久久久免费看 | 精品人人 | 污视频免费网站 | 看黄色一级视频 | 中文字幕亚洲一区 | 波多野结衣中文丝袜字幕 | 亚洲宗合 | 日本高清com | 人人爽人人爽 | 国产福利一区二区在线精品 | 国产日韩欧美 | 一区在线播放 | 成人免费观看网欧美片 | 亚洲高清免费视频 | 欧美在线一区二区三区 | 精品欧美一区二区三区久久久小说 | 国产东北普通话对白 | 在线色| 99re6热视频精品免费观看 | 成人在线精品 | 亚洲热色| 日日摸夜夜摸狠狠摸日日碰夜夜做 | 成人视品 | 波多野结衣三级在线 | 欧美一a一片一级一片 | 天天操天天干天天爽 | 日本久久综合网 | 天天色官网 | 视频二区 | 午夜资源 | 午夜男人女人爽爽爽视频 | 97超精品视频在线观看 |