Table
# FxTable
Used to display multiple sets of structured data with sorting, filtering, comparison or other custom operations.
# Table Attributes
| Attribute | Description | Type | Options | Default |
|---|---|---|---|---|
| data | Table data | array | — | — |
| height | Table's height. Accepts a number (unit: px) or string (will be set as style.height) | string/number | — | — |
| max-height | Table's max-height. Accepts number (unit: px) or string | string/number | — | — |
| stripe | Whether table is striped | boolean | — | false |
| border | Whether table has vertical border | boolean | — | false |
| size | Table size | string | medium / small / mini | — |
| fit | Whether column width fits container | boolean | — | true |
| show-header | Whether table header is visible | boolean | — | true |
| highlight-current-row | Whether current row is highlighted | boolean | — | false |
| current-row-key | Key of current row (write-only) | String,Number | — | — |
| row-class-name | Function that returns custom class names for a row, or assign a string to set same class name for all rows | Function({row, rowIndex})/String | — | — |
| row-style | Function that returns custom style for a row, or assign an object to set same style for all rows | Function({row, rowIndex})/Object | — | — |
| cell-class-name | Function that returns custom class names for a cell, or assign a string to set same class name for all cells | Function({row, column, rowIndex, columnIndex})/String | — | — |
| cell-style | Function that returns custom style for a cell, or assign an object to set same style for all cells | Function({row, column, rowIndex, columnIndex})/Object | — | — |
| header-row-class-name | Function that returns custom class names for a header row, or assign a string to set same class name for all header rows | Function({row, rowIndex})/String | — | — |
| header-row-style | Function that returns custom style for a header row, or assign an object to set same style for all header rows | Function({row, rowIndex})/Object | — | — |
| header-cell-class-name | Function that returns custom class names for a header cell, or assign a string to set same class name for all header cells | Function({row, column, rowIndex, columnIndex})/String | — | — |
| header-cell-style | Function that returns custom style for a header cell, or assign an object to set same style for all header cells | Function({row, column, rowIndex, columnIndex})/Object | — | — |
| row-key | Key of row data, used for optimizing rendering. Required when using reserve-selection or displaying tree data. When type is String, supports multi-level access like user.info.id, but not user.info[0].id (use Function instead) | Function(row)/String | — | — |
| empty-text | Text displayed when data is empty. Can also be set via slot="empty" | String | — | No Data |
| default-expand-all | Whether expand all rows by default (works when table has expandable rows or is tree table) | Boolean | — | false |
| expand-row-keys | Set currently expanded rows (requires row-key). Value is an array of row keys | Array | — | |
| default-sort | Default sort column and order. prop specifies default sorted column, order specifies sort order | Object | order: ascending, descending | If only prop is specified, default order is ascending |
| tooltip-effect | Tooltip's effect property | String | dark/light | dark |
| show-summary | Whether to display summary row | Boolean | — | false |
| sum-text | Text of first column in summary row | String | — | Sum |
| summary-method | Custom summary method | Function({ columns, data }) | — | — |
| span-method | Method that returns merge cell config | Function({ row, column, rowIndex, columnIndex }) | — | — |
| select-on-indeterminate | In multiple selection table, controls behavior when only some rows are selected and checkbox in header is clicked. If true, selects all rows; if false, deselects all | Boolean | — | true |
| indent | Indent of tree node when displaying tree data | Number | — | 16 |
| lazy | Whether to lazy load child node data | Boolean | — | — |
| load | Method for loading child node data (works when lazy is true). Second parameter contains node level info | Function(row, treeNode, resolve) | — | — |
| tree-props | Configuration for rendering nested data | Object | — | { hasChildren: 'hasChildren', children: 'children' } |
# Table Events
| Event Name | Description | Parameters |
|---|---|---|
| select | Triggered when user manually selects a row | selection, row |
| select-all | Triggered when user manually selects all rows | selection |
| selection-change | Triggered when selection changes | selection |
| cell-mouse-enter | Triggered when mouse enters a cell | row, column, cell, event |
| cell-mouse-leave | Triggered when mouse leaves a cell | row, column, cell, event |
| cell-click | Triggered when cell is clicked | row, column, cell, event |
| cell-dblclick | Triggered when cell is double-clicked | row, column, cell, event |
| row-click | Triggered when row is clicked | row, column, event |
| row-contextmenu | Triggered when row is right-clicked | row, column, event |
| row-dblclick | Triggered when row is double-clicked | row, column, event |
| header-click | Triggered when header is clicked | column, event |
| header-contextmenu | Triggered when header is right-clicked | column, event |
| sort-change | Triggered when sorting changes | { column, prop, order } |
| filter-change | Triggered when filtering changes. Parameter is an object where key is column's columnKey and value is array of selected filter conditions | filters |
| current-change | Triggered when current row changes | currentRow, oldCurrentRow |
| header-dragend | Triggered when column width changes by dragging header | newWidth, oldWidth, column, event |
| expand-change | Triggered when row expand status changes (second parameter is expandedRows when expanding, or expanded for tree table) | row, (expandedRows | expanded) |
# Table Methods
| Method | Description | Parameters |
|---|---|---|
| clearSelection | For multiple selection table, clear selection | — |
| toggleRowSelection | For multiple selection table, toggle row selection status. Second parameter sets selection status (true for selected) | row, selected |
| toggleAllSelection | For multiple selection table, toggle selection status of all rows | - |
| toggleRowExpansion | For expandable table or tree table, toggle row expansion status. Second parameter sets expansion status (true for expanded) | row, expanded |
| setCurrentRow | For single selection table, set current row. If no parameter, clears current selection | row |
| clearSort | Clear sorting, data returns to unsorted state | — |
| clearFilter | Clear all filters when no parameter, or clear specified column filters when passing array of columnKeys | columnKey |
| doLayout | Re-layout table. May need to call when table or its ancestor element changes from hidden to visible | — |
| sort | Manually sort table. prop specifies column, order specifies sort order | prop: string, order: string |
# Table Slot
| name | Description |
|---|---|
| append | Content inserted after last row. Useful for infinite scrolling. If table has summary row, this slot will be above it. |
# Table-column Attributes
| Attribute | Description | Type | Options | Default |
|---|---|---|---|---|
| type | Column type. selection shows checkbox, index shows row index (starting from 1), expand shows expand button | string | selection/index/expand | — |
| index | Custom index when type=index. Can be number or function(index) | number, Function(index) | - | - |
| column-key | Column's key. Required when using filter-change event | string | — | — |
| label | Column label | string | — | — |
| prop | Field name for column content. Can also use property | string | — | — |
| width | Column width | string | — | — |
| min-width | Column's min-width. Unlike width which is fixed, min-width distributes remaining width proportionally to columns with min-width | string | — | — |
| fixed | Whether column is fixed to left or right. true means fixed to left | string, boolean | true, left, right | — |
| render-header | Function for rendering header label | Function(h, { column, $index }) | — | — |
| sortable | Whether column is sortable. 'custom' means remote sorting (listen to sort-change event) | boolean, string | true, false, 'custom' | false |
| sort-method | Custom sorting method (works when sortable is true). Should return number like Array.sort | Function(a, b) | — | — |
| sort-by | Specify sort property (works when sortable is true and no sort-method). If array, sorts by first property, then second if equal, etc. | String/Array/Function(row, index) | — | — |
| sort-orders | Sort order rotation when sortable is true. Array elements should be 'ascending', 'descending' or null (resets to original order) | array | ['ascending', 'descending', null] | ['ascending', 'descending', null] |
| resizable | Whether column width can be resized (requires border=true on el-table) | boolean | — | true |
| formatter | Function to format content | Function(row, column, cellValue, index) | — | — |
| show-overflow-tooltip | Show tooltip when content is too long | Boolean | — | false |
| align | Alignment | String | left/center/right | left |
| header-align | Header alignment. Inherits table alignment if not set | String | left/center/right | — |
| class-name | Column's class name | string | — | — |
| label-class-name | Custom class name for column label | string | — | — |
| selectable | Only works when type=selection. Function determines if row's checkbox can be selected | Function(row, index) | — | — |
| reserve-selection | Only works when type=selection. Whether to keep selection after data updates (requires row-key) | Boolean | — | false |
| filters | Filter options array. Elements should have text and value properties | Array[{ text, value }] | — | — |
| filter-placement | Placement of filter popup | String | Same as Tooltip's placement | — |
| filter-multiple | Whether filter is multiple selection | Boolean | — | true |
| filter-method | Filter method. For multiple filters, executes multiple times per row, shows if any returns true | Function(value, row, column) | — | — |
| filtered-value | Selected filter items. Useful when customizing header filter rendering | Array | — | — |
# Table-column Scoped Slot
| name | Description |
|---|---|
| — | Custom column content. Parameters: { row, column, $index } |
| header | Custom header content. Parameters: { column, $index } |
# Basic Table
Basic table display.
# Striped Table
Striped table makes it easier to distinguish different rows.
# Table with Border
# Table with Status
Highlight rows to distinguish different statuses like success, info, warning, danger.
# Fixed Header
Fix the header when scrolling through vertical content.
# Fixed Column
Fix columns when scrolling through horizontal content.
# Fixed Columns and Header
Fix both columns and header when scrolling through horizontal and vertical content.
# Fluid Height
Set a max-height for the table when data volume changes dynamically.
# Multi-level Header
When data structure is complex, use multi-level headers to display data hierarchy.
# Single Selection
Select single row indicated by color block.
# Multiple Selection
Select multiple rows with checkboxes.
# Sorting
Sort the table to quickly find or compare data.
# Filtering
Filter the table to quickly find the data you want.
# Custom Column Template
Customize column display content to combine with other components.
# Expandable Row
When row content is too much and you don't want horizontal scrollbar, use expandable row feature.
# Tree Data and Lazy Loading
# Custom Header
Table header supports customization.
# Summary Row
Display summary row at the table footer for numerical data.
# Merge Cells
Merge rows or columns when multiple rows or columns share the same data.
# Custom Index
Customize row numbers for type=index column.