Skip to content

Table - Merge & Summary

The Table component supports row/column merging and displaying summary rows.

Merge Rows or Columns

Implement row or column merging via the span-method property.

Date
Name
Province
City
Address
2024-01-01
John
Beijing
Chaoyang
88 Jianguo Rd
Beijing
Haidian
Zhongguancun St
2024-01-02
Jane
Shanghai
Pudong
Lujiazui
Shanghai
Jing'an
Nanjing West Rd
2024-01-03
Mike
Guangdong
Tianhe
Zhujiang New Town
Merge Rows

Merge Header

Define multi-level headers via the children property of columns. Set label and children for parent columns, while leaf children are the actual data columns. The table automatically calculates colspan and rowspan to generate grouped headers.

Basic Info
Address Info
Name
Age
Province
City
Detail Address
Zip
John
28
Beijing
Chaoyang
88 Jianguo Rd
100020
Jane
32
Shanghai
Pudong
Lujiazui Ring Rd
200120
Mike
25
Guangdong
Tianhe
Zhujiang New Town
510623
Sarah
30
Zhejiang
Xihu
Wensan Rd
310012
Merge Header

Case Study: Permission Management Table

Combine span-method row merging with the column render function to implement a common Permission Configuration Matrix. The Module and Feature columns automatically merge rows with identical values. Selection for types and specific permissions are implemented via checkboxes rendered with h(), supporting four-level selection linkage across modules, features, types, and permissions.

Module
Feature
Type
Permissions
Permission Management Table

Configure the summary row via summary-config and set method for custom summary logic.

Name
Amount 1
Amount 2
John
1000
500
Jane
2000
800
Summary Footer Row

API

Multi-level Header (Merge Header)

Implement multi-level headers via the children property of column configurations.

PropertyDescriptionTypeDefault
labelTitle text of the grouped headerstring
childrenChild column configurations (supports nested multi-layers)TableColumn[]
headerAlignHeader alignment'left' | 'center' | 'right''center' (Grouped columns default to center)
headerClassNameCustom header class namestring
headerStyleCustom header styleCSSProperties

Note: Parent columns (those with children) only need a label and do not require a prop. colspan and rowspan are automatically calculated by the component.

span-method

ParameterDescriptionType
rowCurrent row dataRecord<string, unknown>
columnCurrent column configurationTableColumn
rowIndexCurrent row indexnumber
columnIndexCurrent column indexnumber

Return Value: { rowspan: number, colspan: number } or [rowspan, colspan]

  • rowspan: 0, colspan: 0 indicates the cell is merged (not rendered)
  • rowspan: n means spanning n rows, colspan: n means spanning n columns

SummaryConfig

PropertyDescriptionTypeDefault
textText of the first column in the summary rowstring'Total'
positionSummary row position'top' | 'bottom''bottom'
fixedWhether to fix the summary rowbooleanfalse
methodSummary calculation method({ columns, data }) => Array<string | number | VNode>
classNameSummary row class namestring | ((params) => string)
styleSummary row styleCSSProperties | ((params) => CSSProperties)

Column render Function

ParameterDescriptionType
rowCurrent row dataRecord<string, unknown>
columnCurrent column configurationTableColumn
rowIndexCurrent row indexnumber
cellValueCurrent cell valueunknown

Return Value: VNode (Create via Vue h() function)

Released under the MIT License.