小明永久免费大陆在线观看-小明永久免费视频-小明永久视频免费播放-小嫩妇好紧好爽再快视频-小嫩嫩12欧美-小日本xxx

首頁 生活 > 正文

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.zhigu.net.cn All rights reserved
聯系我們:39 60 29 14 [email protected]
皖ICP備2022009963號-3

亚洲精品v欧洲精品v日韩精品 | av无码精品一区二区三区 | 黑人巨大精品欧美 | 国产91在线看 | 精品亚洲麻豆1区2区3区 | 天躁夜夜躁狼狠躁 | 人人妻人人妻人人片av | 久久精品国产亚洲夜色av网站 | 久久精品国产亚洲av麻豆图片 | 成人在线免费电影 | 国产精品久久国产精麻豆99网站 | а√最新版在线天堂 | 熟妇人妻va精品中文字幕 | 一本大道av伊人久久综合 | 国产白丝jk捆绑束缚调教视频 | 中文字幕熟妇人妻在线视频 | 国产精品久久久久乳精品爆 | 国产午夜视频在线观看网站 | 国产伦子沙发午休系列资源曝光 | 少妇被黑人到高潮喷出白浆 | 久久精品夜色国产亚洲av | 精品国产免费一区二区 | 九九精品99久久久香蕉 | 极品美女一区二区三区视频 | 精品亚洲一区二区三区 | 久久夜色精品国产噜噜麻豆 | 97久久草草超级碰碰碰 | 天天鲁一鲁摸一摸爽一爽 | 日韩毛片无码永久免费看 | 美丽人妻在夫前被黑人 | 国产又色又爽无遮挡免费 | 国产一区二区三区视频 | 久久久久人妻精品一区三寸 | 最近中文字幕mv在线资源 | 亚洲乱妇老熟女爽到高潮的片 | 久久精品天天爽夜夜爽 | 成人观看天堂在线影片 | 一性一交一口添一摸视频 | 国产高清在线看免费视频观 | 少妇无码一区二区三区免费 | 中文字幕无码无码专区 |