Skip to content
Latestv1.0.60

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.

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.

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.

Permission Management Table

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

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.