Skip to content

Table

A secondary encapsulation of the element-plus table component. Simplifies table configuration.

Basic Usage

Tree Table

Functional Table

Table Attributes

AttributeDescriptionTypeExtensibleDefault Value
dataTable dataArrayNo
columnsColumn configurationTableColumn[]Yes
heightHeight of the table. Defaults to automatic height, and the table's height is controlled by external styles.enumNo
max-heightMaximum height of the tableenumNo
stripeWhether to use striped rowsbooleanNofalse
borderWhether to have vertical bordersbooleanNotrue
sizeSize of the TableenumNo
fitWhether the column width should stretch to fitbooleanNotrue
show-headerWhether to show the table headerbooleanNotrue
highlight-current-rowWhether to highlight the current rowbooleanNofalse
current-row-keyKey of the current row, read-onlyenumNo
row-class-nameCallback method for row className, or use a string to set a fixed className for all rows.enumNo
row-styleCallback method for row style, or use a fixed Object to set the same style for all rows.enumNo
cell-class-nameCallback method for cell className, or use a string to set a fixed className for all cells.enumNo
cell-styleCallback method for cell style, or use a fixed Object to set the same style for all cells.enumNo
header-row-class-nameCallback method for header row className, or use a string to set a fixed className for all header rows.enumNo
header-row-styleCallback method for header row style, or use a fixed Object to set the same style for all header rows.enumNo
header-cell-class-nameCallback method for header cell className, or use a string to set a fixed className for all header cells.enumNo
header-cell-styleCallback method for header cell style, or use a fixed Object to set the same style for all header cells.enumNo
row-keyKey for row data to optimize Table rendering; required when using reserve-selection functionality or displaying tree data.enumNoid
empty-textText content to display when there is no data; can also be set through a slot.stringNoNo Data
default-expand-allWhether to expand all rows by default, effective when the Table contains expandable rows or is a tree table.booleanNofalse
expand-row-keysSet the currently expanded rows using this property; needs row-key to be set, this property is an array of expanded row keys.ArrayNo
default-sortDefault sorting column's prop and order. The prop attribute specifies the default sorting column, order specifies the default sorting order.objectNoprop set, order default ascending
tooltip-effectEffect of the overflow tooltipenumNodark
tooltip-optionsOptions for overflow tooltip, refer to the tooltip component below.objectNoobject
show-summaryWhether to show a summary row at the bottom of the tablebooleanNofalse
sum-textText to display in the first column of the summary rowstringNoSum
summary-methodCustom summary calculation methodFunctionNo
span-methodMethod to merge rows or columnsFunctionNo
select-on-indeterminateIn a multi-select table, the behavior when only some rows are selected and the header checkbox is clicked. If true, select all rows; if false, deselect all rows.booleanNotrue
indentIndentation of tree nodes when displaying tree datanumberNo16
lazyWhether to lazily load child node databooleanNofalse
loadFunction to load child node data, effective when lazy is true.FunctionNo
tree-propsConfiguration options for rendering nested dataobjectNoobject
table-layoutSet the layout method for table cells, rows, and columnsenumNofixed
scrollbar-always-onAlways show scrollbarsbooleanNofalse
show-overflow-tooltipWhether to hide extra content and use Tooltip to show them on hover. This affects the display of all columns.enumNo
flexibleEnsure the minimum size of the main axis to avoid overflow of content.booleanNofalse

TableColumn Attributes

AttributeDescriptionTypeExtensibleDefault Value
typeColumn type. If set to selection, shows a checkbox; if set to index, shows the row index (starting from 1); if set to expand, shows an expandable button.enumNodefault
indexIf type=index is set, you can use the index property to customize the index.enumNo
labelDisplay titlestringNo
column-keyColumn key, required to identify which column's filter conditions are being used for filter-change events.stringNo
propField name corresponding to the column's content, can also use the property attribute.stringNo
widthWidth of the columnenumNo''
min-widthMinimum width of the column. Unlike width, min-width allocates remaining width proportionally to columns with min-width set.enumNo''
fixedWhether the column is fixed to the left or right. True indicates fixed to the left.enumNofalse
render-headerFunction for rendering the column header label areaFunctionNo
sortableWhether the column can be sorted. If set to 'custom', remote sorting is needed and the Table's sort-change event needs to be listened to.enumNofalse
sort-methodSpecify which property the data is sorted by, valid only when sortable is true. Should return a Number like Array.sort.FunctionNo
sort-bySpecify which property the data is sorted by, valid only when sortable is true and no sort-method is set. If sort-by is an array, it sorts by the first property, then the second if the first is the same.enumNo
sort-ordersthe order of the sorting strategies used when sorting the data, works when sortable is true. Accepts an array, as the user clicks on the header, the column is sorted in order of the elements in the arrayobjectNo['ascending', 'descending', null]
resizablewhether column width can be resized, works when border of el-table is truebooleanNotrue
formatterfunction that formats cell contentFunctionNo
show-overflow-tooltipwhether to hide extra content and show them in a tooltip when hovering on the cellenumNoundefined
alignalignmentenumNocenter
header-alignalignment of the table header. If omitted, the value of the above align attribute will be appliedenumNocenter
class-nameclass name of cells in the columnstringNo
class-nameclass name of the label of this columnstringNo
label-class-namestringNo
selectablefunction that determines if a certain row can be selected, works when type is 'selection'FunctionNo
reserve-selectionwhether to reserve selection after data refreshing, works when type is 'selection'. Note that row-key is required for this to workbooleanNofalse
filtersan array of data filtering options. For each element in this array, text and value are requiredobjectNo
filter-placementplacement for the filter dropdownenumNo
filter-class-nameclassName for the filter dropdownstringNo
filter-multiplewhether data filtering supports multiple optionsbooleanNotrue
filter-methoddata filtering method. If filter-multiple is on, this method will be called multiple times for each row, and a row will display if one of the calls returns truefunctionNo
filtered-valuefilter value for selected data, might be useful when table header is rendered with render-headerobjectNo

Slots

NameDescriptionType
${prop}Slot for data columns, suitable for complex data processingobject
header-${prop}General header slot, associated through the prop of columns itemobject
appendContent inserted after the last row of the table-
emptyCustom content when data is empty-

Events

NameDescriptionTypeExpand
selectEvent triggered when the user manually checks a data row's checkboxFunctionNo
select-allEvent triggered when the user manually checks the "select all" checkboxFunctionNo
selection-changeEvent triggered when the selected items changeFunctionNo
cell-mouse-enterEvent triggered when hovering enters a cellFunctionNo
cell-mouse-leaveEvent triggered when hovering leaves a cellFunctionNo
cell-clickEvent triggered when a cell is clickedFunctionNo
cell-dblclickEvent triggered when a cell is double-clickedFunctionNo
cell-contextmenuEvent triggered when a cell is right-clickedFunctionNo
row-clickEvent triggered when a row is clickedFunctionNo
row-contextmenuEvent triggered when a row is right-clickedFunctionNo
row-dblclickEvent triggered when a row is double-clickedFunctionNo
header-clickEvent triggered when a column header is clickedFunctionNo
header-contextmenuEvent triggered when a column header is right-clickedFunctionNo
sort-changeEvent triggered when the table's sorting conditions changeFunctionNo
filter-changeKey of the column; if you need to use the filter-change event, this property identifies which column's filter conditionFunctionNo
current-changeEvent triggered when the table's current row changes. If you want to highlight the current row, enable the table's highlight-current-row propertyFunctionNo
header-dragendEvent triggered when the width of a column is changed by dragging the column headerFunctionNo
expand-changeEvent triggered when a user expands or collapses a row (when expanding rows, the second parameter of the callback is expandedRows; for tree tables, the second parameter is expanded)FunctionNo

Table Exposes

Method NameDescriptionType
getTableRefGet the el-table instance. Methods under El-Table Exposes need to be called on the instance obtained from this method.Function

El-Table Exposes

Method NameDescriptionType
clearSelectionFor multi-select tables, clear the user's selectionFunction
getSelectionRowsReturn the currently selected rowsFunction
toggleRowSelectionFor multi-select tables, toggle the selection state of a specific row. With a second parameter, you can directly set the row's selection state.Function
toggleAllSelectionFor multi-select tables, toggle between select all and deselect allFunction
toggleRowExpansionFor expandable tables or tree tables, toggle expansion for a row. With a second parameter, you can directly set whether the row should be expanded or collapsed.Function
setCurrentRowFor single-select tables, set a row as the selected row. If called without parameters, it will cancel the selection of the currently highlighted row.Function
clearSortClear the sorting condition, reverting the data to an unsorted stateFunction
clearFilterClear the filter conditions for specified columns. If no parameters are passed, clear all filters.Function
doLayoutRe-layout the Table. You may need to call this method to get the correct layout when the table's visibility changes.Function
sortManually sort the table. The prop attribute specifies the sorting column, and order specifies the sorting order.Function
scrollToScroll to a specific set of coordinatesFunction
setScrollTopSet the vertical scroll positionFunction
setScrollLeftSet the horizontal scroll positionFunction
columns el^2.7.6Get the context of the table columnsarray

Released under the MIT License