API Reference
This page is the behavioral reference: props, events, slots, defaults and controlled/uncontrolled rules.
For the full relationships of TypeScript types such as TableColumnsType, Breakpoint and RowSelection, see the type reference (Chinese). Complete declarations are available in Type Declarations below.
Import entry
Import components, constants and types from @vtable-guild/vtable-guild:
import {
VTable,
VTableSummary,
EXPAND_COLUMN,
SELECTION_COLUMN,
type TableColumnsType,
type RowSelection,
type Expandable,
} from '@vtable-guild/vtable-guild'VTable Props
Data and structure
| Prop | Type | Default | Description |
|---|---|---|---|
dataSource | TRecord[] | [] | Table data source. |
pagination | false | TablePaginationConfig | false | Pass {} to enable local or remote pagination; see pagination. |
columns | TableColumnsType<TRecord> | [] | Column configuration: leaf columns, column groups and sentinel constants. |
columnOrder | Key[] | - | Column display order. See column display (Chinese). |
rowKey | string | ((record: TRecord) => Key) | - | Unique row identity; passing it explicitly is recommended. |
childrenColumnName | string | 'children' | Child field name for tree data. |
indentSize | number | 15 | Tree data indent width in px. |
Visuals and layout
| Prop | Type | Default | Description |
|---|---|---|---|
size | 'small' | 'middle' | 'large' | 'large' | Table size, aligned with ant-design-vue naming. |
loading | boolean | { spinning?: boolean; indicator?: VNodeChild; tip?: string } | false | Loading state; the object form accepts spinning, indicator, tip. |
bordered | boolean | false | Show borders. |
striped | boolean | false | Zebra striping. |
hoverable | boolean | true | Row hover highlight. |
tableLayout | 'auto' | 'fixed' | - | Table layout mode. |
showHeader | boolean | true | Whether to show the header. |
headerEllipsis | boolean | false | Also ellipsize headers of columns with column.ellipsis. |
class | string | - | Extra class on the root node. |
Scrolling and positioning
| Prop | Type | Default | Description |
|---|---|---|---|
scroll | { x?: number | string; y?: number | string; scrollToFirstRowOnChange?: boolean } | - | Horizontal and vertical scroll config; providing y creates a fixed-header scroll area. A numeric y sets a fixed viewport; y: 'auto' fills a parent with a definite height and deducts the header and external summary. In virtual mode, other strings must be positive pixel values; relative units fall back to 400px with a development warning. scrollToFirstRowOnChange resets vertical scroll after sort/filter/paginate; defaults to true with pagination and false otherwise. |
sticky | boolean | TableSticky | false | Sticky header, summary or horizontal scrollbar config. |
virtual | boolean | false | Enable virtual scrolling; requires scroll.y. |
virtualColumn | boolean | false | Horizontal virtualization: render only columns in the viewport; requires virtual. Pays off with many columns, see virtualization (Chinese). |
rowHeight | number | - | Fixed row height (px), only in virtual mode. Declaring it skips all row measurement and makes viewport math O(1) — only pass it if every row truly has that height. |
getPopupContainer | (triggerNode: HTMLElement) => HTMLElement | - | Mount container for filter, selection and page-size menus. |
Theming and locale
| Prop | Type | Default | Description |
|---|---|---|---|
ui | SlotProps<{ slots: Record<TableSlots, string> }> | - | Theme slot class overrides for this table instance. See the ui slot reference (Chinese). |
locale | LocaleName | global config or 'zh-CN' | Locale identifier for this table instance. |
locales | LocaleRegistry | {} | Extra locale packs registered on this instance. |
localeOverrides | DeepPartial<VTableGuildTableLocale> | {} | Partial locale overrides for this instance. |
Interactive capabilities
| Prop | Type | Default | Description |
|---|---|---|---|
rowSelection | RowSelection<TRecord> | - | Enable the selection column. |
expandable | Expandable<TRecord> | - | Enable expandable rows. |
rowDraggable | boolean | false | Enable row drag sorting, see row drag sort (Chinese). |
expandedRowKeys | Key[] | - | Controlled expanded keys for tree data. |
defaultExpandedRowKeys | Key[] | - | Default expanded keys for tree data. |
defaultExpandAllRows | boolean | false | Expand all tree nodes by default. |
onExpand | (expanded: boolean, record: TRecord) => void | - | Tree expand/collapse callback. |
onExpandedRowsChange | (expandedKeys: Key[]) => void | - | Tree expanded-keys callback. |
transformCellText | TransformCellText<TRecord> | - | Transform cell text; opt contains text, column, record and index. |
showSorterTooltip | boolean | true | Table-level sorter tooltip switch, overridable per column. |
sortDirections | SortOrder[] | - | Table-level sort direction list, used as the default for columns. |
Custom structure
| Prop | Type | Default | Description |
|---|---|---|---|
rowClassName | string | RowClassName<TRecord> | - | Extra class for body rows. |
customRow | GetComponentProps<TRecord> | - | Inject attributes, events and styles on body rows. |
customHeaderRow | (columns: (ColumnType<TRecord> | ColumnGroupType<TRecord>)[], index?: number) => CellAdditionalProps | - | Inject attributes, events and styles on header rows. |
title | (data: TRecord[]) => VNodeChild | - | Table title render function. |
footer | (data: TRecord[]) => VNodeChild | - | Table footer render function. |
Column behavior
Basics
| Field | Type | Default | Description |
|---|---|---|---|
key | Key | - | Unique column identity; passing it explicitly is recommended. |
title | ColumnTitle<TRecord> | - | Column title: text, VNode or render function. |
dataIndex | DataIndex | - | Data field path, e.g. 'name' or ['address', 'city']. |
width | number | string | - | Column width; numbers are treated as px. |
align | AlignType | - | Cell content alignment. |
ellipsis | boolean | { showTitle?: boolean } | false | Ellipsize overflowing cell content; showTitle: false disables the hover tooltip. |
className | string | - | Extra class for the column's cells. |
colSpan | number | - | Header cell colSpan. |
visible | boolean | true | Whether the column is shown, see column display (Chinese). |
responsive | Breakpoint[] | - | Show the column when any listed breakpoint matches the screen. |
Custom rendering
| Field | Type | Default | Description |
|---|---|---|---|
customRender | (ctx: CustomRenderContext<TRecord>) => VNodeChild | RenderedCell | - | Custom body cell content. Returning RenderedCell also sets cell props. |
customCell | GetComponentProps<TRecord, TRecord> | - | Inject attributes, events and styles on body cells. |
customHeaderCell | GetComponentProps<ColumnType<TRecord> | ColumnGroupType<TRecord>, TRecord> | - | Inject attributes, events and styles on header cells. |
import type { TableColumnType } from '@vtable-guild/vtable-guild'
interface NameRow {
key: number
name: string
}
const nameColumn: TableColumnType<NameRow> = {
key: 'name',
dataIndex: 'name',
customRender: ({ text, index }) =>
index === 0
? { children: String(text), props: { colSpan: 2, style: { fontWeight: 'bold' } } }
: String(text),
}Fixed columns and resizing
| Field | Type | Default | Description |
|---|---|---|---|
fixed | 'left' | 'right' | true | - | Fixed side; true equals 'left'. |
resizable | boolean | false | Whether the column width is drag-adjustable. |
minWidth | number | - | Leaf-column minimum in auto/fixed layouts and resizing, in finite nonnegative CSS pixels. Unset values add no layout minimum; resizing alone defaults to 50px. |
maxWidth | number | - | Maximum resize target only; minWidth wins if the two conflict. |
width is a target and cannot override a valid minWidth, including explicit 0. Negative or non-finite minimums are treated as unset. All visible leaf columns retain their minimums while another column is resized, regardless of resizable. If their total minimum exceeds the container, the table scrolls horizontally even without scroll.x. Group-header widths follow their children. Updating or removing a minimum recalculates the layout.
Resizing starts from the measured cell width and emits (column: ColumnType<TRecord>, width: number) => void on release after a valid move. The event reports the constrained target; auto-layout content can make the rendered column wider. The component does not mutate the supplied column configuration. Existing minimums may now cause wider columns or earlier horizontal overflow.
Sorting
| Field | Type | Default | Description |
|---|---|---|---|
sorter | ColumnSorter<TRecord> | - | Enable sorting: default compare, custom compare fn or multi-column object. |
sortOrder | SortOrder | - | Controlled sort order. |
defaultSortOrder | SortOrder | - | Uncontrolled default order, effective on first render only. |
sortDirections | SortOrder[] | ['ascend', 'descend'] | Sort directions available for this column. |
showSorterTooltip | boolean | inherits table config | Column-level sorter tooltip switch. |
Table-level sortDirections and showSorterTooltip act as defaults; column-level config wins.
Filtering
| Field | Type | Default | Description |
|---|---|---|---|
filters | ColumnFilterItem[] | - | Filter menu items; renders the filter icon in the header. |
onFilter | (value: string | number | boolean, record: TRecord) => boolean | - | Filter function; return true to keep the row. |
filterMultiple | boolean | true | Whether multiple filter values can be picked. |
filteredValue | Array<string | number | boolean> | null | - | Controlled filter values. |
defaultFilteredValue | Array<string | number | boolean> | - | Uncontrolled default filter values. |
customFilterDropdown | boolean | false | Use the table-level customFilterDropdown slot. |
filterSearch | boolean | ((input: string, filter: ColumnFilterItem) => boolean) | false | Search within filter items. |
filterMode | 'menu' | 'tree' | 'menu' | Filter item presentation mode. |
filterResetToDefaultFilteredValue | boolean | false | Reset restores the default filter values. |
filterDropdownOpen | boolean | - | Controlled filter dropdown visibility. |
onFilterDropdownOpenChange | (visible: boolean) => void | - | Filter dropdown visibility callback. |
filtered | boolean | - | Externally control the filter icon highlight; does not filter. |
filterIcon | (opt: { filtered: boolean }) => VNodeChild | - | Custom filter icon. |
filterDropdown | VNodeChild | ((props: CustomFilterDropdownSlotProps<TRecord>) => VNodeChild) | - | Column-level custom filter panel; overrides the table slot. |
Column groups
| Field | Type | Default | Description |
|---|---|---|---|
children | Array<ColumnType<TRecord> | ColumnGroupType<TRecord>> | - | Child columns. With children present the column is a group. |
Column groups do not receive leaf-column behaviors such as sorting, filtering, dataIndex and customRender.
Row Selection
rowSelection enables the selection column: multiple, single, tree-linked, batch menus and controlled state.
| Field | Type | Default | Description |
|---|---|---|---|
type | 'checkbox' | 'radio' | 'checkbox' | Selection type. |
selectedRowKeys | Key[] | - | Controlled selected keys. |
defaultSelectedRowKeys | Key[] | - | Default selected keys. |
onChange | (selectedRowKeys: Key[], selectedRows: TRecord[]) => void | - | Selection change callback. |
onSelect | (record: TRecord, selected: boolean, selectedRows: TRecord[]) => void | - | Single-row selection callback. |
onSelectMultiple | (selected: boolean, selectedRows: TRecord[], changeRows: TRecord[]) => void | - | Shift multi-select callback. |
onSelectAll | (selected: boolean, selectedRows: TRecord[], changeRows: TRecord[]) => void | - | Select-all callback. |
onSelectInvert | (selectedRowKeys: Key[]) => void | - | Invert-selection callback. |
onSelectNone | () => void | - | Clear-selection callback. |
getCheckboxProps | (record: TRecord) => { disabled?: boolean; name?: string } | - | Inject attributes on selection controls. |
columnWidth | number | string | - | Selection column width. |
fixed | boolean | 'left' | 'right' | - | Fixed position of the selection column. |
columnTitle | string | VNodeChild | - | Selection column header content. |
renderCell | (value: boolean, record: TRecord, index: number, originNode: VNodeChild) => VNodeChild | RenderedCell | - | Custom selection cell. |
checkStrictly | boolean | true | Parent/child independent selection in tree data. |
selections | boolean | (SelectionItem | SelectionSentinel)[] | false | Default or custom batch-selection menu. |
hideSelectAll | boolean | false | Hide the select-all checkbox and dropdown. |
preserveSelectedRowKeys | boolean | false | Keep selected keys when the data source changes. |
Default batch-selection constants: see SelectionSentinel (Chinese).
With pagination enabled, the header checkbox and invert selection affect the current page. The “Select all data” menu (selections: true or [SELECTION_ALL]) selects all loaded, selectable records after filtering. Use preserveSelectedRowKeys: true to retain selected keys and records across remote pages; unloaded pages are never fetched automatically. See pagination.
Expandable
expandable configures expandable row content. Tree-data expand props live at the VTable top level.
| Field | Type | Default | Description |
|---|---|---|---|
expandedRowRender | (record: TRecord, index: number, indent: number, expanded: boolean) => VNodeChild | - | Expanded row content render function. |
expandedRowKeys | Key[] | - | Controlled expanded row keys. |
defaultExpandedRowKeys | Key[] | - | Default expanded row keys. |
expandRowByClick | boolean | false | Expand on full-row click. |
expandIcon | (props: { expanded: boolean; record: TRecord; expandable: boolean; onExpand: (record: TRecord, e: Event) => void }) => VNodeChild | - | Custom expand icon. |
onExpand | (expanded: boolean, record: TRecord) => void | - | Expand/collapse callback. |
onExpandedRowsChange | (expandedKeys: Key[]) => void | - | Expanded-keys callback. |
columnWidth | number | string | - | Expand column width. |
fixed | 'left' | 'right' | true | - | Fixed position of the expand column; true = 'left'. |
defaultExpandAllRows | boolean | false | Expand all rows by default. |
rowExpandable | (record: TRecord) => boolean | - | Whether a row is expandable. |
showExpandColumn | boolean | true | Whether to show the expand column. |
expandedRowClassName | string | RowClassName<TRecord> | - | Class for expanded rows. |
Events
TRecord is your business row type. VTableEventProps<TRecord> provides callback types for template listeners and event props. For pagination only, use pagination.onChange(page, pageSize); the table event reads pagination from extra.pagination.
| Event | Payload | Description |
|---|---|---|
change | (filters: TableFiltersInfo, sorter: VTableSorterResult<TRecord>, extra: TableChangeExtra<TRecord>) => void | Unified event after sorting, filtering, selection and pagination. |
resizeColumn | (column: ColumnType<TRecord>, width: number) => void | Fired after a column resize drag ends. |
rowDragEnd | (newData: TRecord[], info: RowDragSortInfo) => void | Fired when row drag sorting finishes with a changed order, see row drag sort (Chinese). |
change keeps its three arguments. Enabled pagination adds extra.pagination; actions are 'sort', 'filter', 'select' and 'paginate'.
extra.currentDataSource contains processed data before pagination for sort/filter/paginate, and displayed page data for selection. Remote data is limited to loaded records.
import { ref } from 'vue'
import type { VTableEventProps } from '@vtable-guild/vtable-guild'
interface Row {
key: number
name: string
}
const current = ref(1)
const pageSize = ref(10)
const handleChange: NonNullable<VTableEventProps<Row>['onChange']> = (_filters, _sorter, extra) => {
if (extra.action !== 'paginate' || !extra.pagination) return
current.value = extra.pagination.current
pageSize.value = extra.pagination.pageSize
}Slots
| Slot | Payload type | Description |
|---|---|---|
bodyCell | TableBodyCellSlotProps<TRecord> | Custom cell content. |
headerCell | TableHeaderCellSlotProps<TRecord> | Custom header cell content. |
empty | () | Custom empty state. |
loading | () | Custom loading state. |
customFilterDropdown | CustomFilterDropdownSlotProps<TRecord> | Table-level custom filter panel. |
customFilterIcon | { column: ColumnType<TRecord>; filtered: boolean } | Table-level custom filter icon. |
title | TableDataSlotProps<TRecord> | Custom title area. |
footer | TableDataSlotProps<TRecord> | Custom footer area. |
summary | () | Custom summary area. |
paginationItem | TablePaginationSlotProps | Content at { slot: 'name' } in pagination.layout. |
These are Vue slots. To restyle structure via classes, see the ui slot reference (Chinese).
paginationItem receives the extension name, effective pagination state, pageCount, range, disabled, position and region. Keep selection and request functions in the parent; bind disabled to application buttons as needed. Extensions share the pagination row's visibility, including empty-data and single-page hiding. See composable layouts and content slots.
VTableSummary
VTableSummary renders summary rows.
| Component | Common props | Description |
|---|---|---|
VTableSummary | fixed?: SummaryFixed | Summary container; fixed accepts true, 'top', 'bottom'. |
VTableSummary.Row | - | Summary row. |
VTableSummary.Cell | index: number (required), colSpan?: number, rowSpan?: number, align?: AlignType | Summary cell. |
Related pages
- Type reference (Chinese)
- ui slot reference (Chinese)
- Sorting (Chinese)
- Filtering (Chinese)
Pagination
pagination?: false | TablePaginationConfig defaults to disabled. Pass {} to enable. See configuration and examples. scroll.scrollToFirstRowOnChange?: boolean controls vertical scroll reset on sort/filter/paginate; enabled pagination defaults to true, other tables retain their previous behavior.
Type Declarations
Types are imported from @vtable-guild/vtable-guild. Shared supporting types are indexed in the type reference (Chinese). Summary props below are documentation helper types, not named package exports.
Props and columns
export interface TableProps<TRecord extends object = Record<string, any>> {
pagination?: false | TablePaginationConfig
dataSource: TRecord[]
columns: ColumnsType<TRecord>
columnOrder?: Key[]
rowKey?: string | ((record: TRecord) => Key)
loading?: boolean | { spinning?: boolean; indicator?: VNodeChild; tip?: string }
size?: 'small' | 'middle' | 'large'
bordered?: boolean
striped?: boolean
hoverable?: boolean
rowDraggable?: boolean
ui?: SlotProps<{ slots: Record<TableSlots, string> }>
class?: string
tableLayout?: TableLayout
showHeader?: boolean
headerEllipsis?: boolean
rowClassName?: string | RowClassName<TRecord>
customRow?: GetComponentProps<TRecord>
customHeaderRow?: (
columns: Array<ColumnType<TRecord> | ColumnGroupType<TRecord>>,
index?: number,
) => CellAdditionalProps
showSorterTooltip?: boolean
sortDirections?: SortOrder[]
locale?: LocaleName
locales?: LocaleRegistry
localeOverrides?: DeepPartial<VTableGuildTableLocale>
sticky?: boolean | TableSticky
getPopupContainer?: (triggerNode: HTMLElement) => HTMLElement
transformCellText?: TransformCellText<TRecord>
rowSelection?: RowSelection<TRecord>
expandable?: Expandable<TRecord>
title?: (data: TRecord[]) => VNodeChild
footer?: (data: TRecord[]) => VNodeChild
scroll?: { x?: number | string; y?: number | string; scrollToFirstRowOnChange?: boolean }
virtual?: boolean
rowHeight?: number
virtualColumn?: boolean
childrenColumnName?: string
indentSize?: number
expandedRowKeys?: Key[]
defaultExpandedRowKeys?: Key[]
defaultExpandAllRows?: boolean
onExpand?: (expanded: boolean, record: TRecord) => void
onExpandedRowsChange?: (expandedKeys: Key[]) => void
}export interface ColumnType<TRecord extends object = Record<string, any>> {
key?: Key
title?: ColumnTitle<TRecord>
dataIndex?: DataIndex
width?: number | string
align?: AlignType
ellipsis?: boolean | { showTitle?: boolean }
className?: string
colSpan?: number
customRender?: (ctx: CustomRenderContext<TRecord>) => VNodeChild | RenderedCell
customCell?: GetComponentProps<TRecord, TRecord>
customHeaderCell?: GetComponentProps<ColumnType<TRecord> | ColumnGroupType<TRecord>, TRecord>
fixed?: 'left' | 'right' | true
resizable?: boolean
minWidth?: number
maxWidth?: number
sorter?: ColumnSorter<TRecord>
sortOrder?: SortOrder
defaultSortOrder?: SortOrder
sortDirections?: SortOrder[]
filters?: ColumnFilterItem[]
onFilter?: (value: string | number | boolean, record: TRecord) => boolean
filterMultiple?: boolean
filteredValue?: (string | number | boolean)[] | null
defaultFilteredValue?: (string | number | boolean)[]
customFilterDropdown?: boolean
filterSearch?: boolean | ((input: string, filter: ColumnFilterItem) => boolean)
filterMode?: 'menu' | 'tree'
filterResetToDefaultFilteredValue?: boolean
filterDropdownOpen?: boolean
onFilterDropdownOpenChange?: (visible: boolean) => void
filtered?: boolean
filterIcon?: (opt: { filtered: boolean }) => VNodeChild
filterDropdown?: VNodeChild | ((props: CustomFilterDropdownSlotProps<TRecord>) => VNodeChild)
showSorterTooltip?: boolean
visible?: boolean
responsive?: Breakpoint[]
}export interface ColumnGroupType<TRecord extends object = Record<string, any>> extends Omit<
ColumnType<TRecord>,
| 'dataIndex'
| 'customRender'
| 'sorter'
| 'sortOrder'
| 'defaultSortOrder'
| 'sortDirections'
| 'filters'
| 'onFilter'
| 'filterMultiple'
| 'filteredValue'
| 'defaultFilteredValue'
| 'customFilterDropdown'
| 'filterSearch'
| 'filterMode'
| 'filterResetToDefaultFilteredValue'
| 'filterDropdownOpen'
| 'onFilterDropdownOpenChange'
| 'filtered'
| 'filterIcon'
| 'filterDropdown'
> {
children: Array<ColumnType<TRecord> | ColumnGroupType<TRecord>>
}export type ColumnsType<TRecord extends object = Record<string, any>> = Array<
ColumnType<TRecord> | ColumnGroupType<TRecord> | ColumnSentinel
>export interface ColumnTitleProps<TRecord extends object = Record<string, any>> {
sortOrder?: SortOrder
sortColumn?: ColumnType<TRecord>
sortColumns?: Array<{ column: ColumnType<TRecord>; order: SortOrder }>
filters?: Record<string, (string | number | boolean)[] | null>
}export type ColumnTitle<TRecord extends object = Record<string, any>> =
| VNodeChild
| ((props: ColumnTitleProps<TRecord>) => VNodeChild)export type GetComponentProps<TData, TRecord extends object = Record<string, any>> = (
data: TData,
index: number,
column?: ColumnType<TRecord>,
) => CellAdditionalProps | undefinedexport interface CustomRenderContext<TRecord extends object = Record<string, any>> {
text: unknown
value: unknown
record: TRecord
index: number
renderIndex: number
column: ColumnType<TRecord>
}export interface RenderedCell {
props?: CellAdditionalProps
children?: VNodeChild
}export interface CellAdditionalProps {
class?: string
className?: string
style?: CSSProperties
colSpan?: number
rowSpan?: number
colspan?: number
rowspan?: number
onClick?: (event: MouseEvent) => void
onMouseenter?: (event: MouseEvent) => void
onMouseleave?: (event: MouseEvent) => void
[key: string]: unknown
}export type RowClassName<TRecord = Record<string, any>> = (
record: TRecord,
index: number,
indent: number,
) => stringexport type TransformCellText<TRecord extends object = Record<string, any>> = (opt: {
text: unknown
column: ColumnType<TRecord>
record: TRecord
index: number
}) => unknownexport interface TableSticky {
offsetHeader?: number
offsetSummary?: number
offsetScroll?: number
getContainer?: () => Window | HTMLElement
}Selection and expansion
export interface RowSelection<TRecord extends object = Record<string, any>> {
preserveSelectedRowKeys?: boolean
type?: RowSelectionType
selectedRowKeys?: Key[]
defaultSelectedRowKeys?: Key[]
onChange?: (selectedRowKeys: Key[], selectedRows: TRecord[]) => void
onSelect?: (record: TRecord, selected: boolean, selectedRows: TRecord[]) => void
onSelectMultiple?: (selected: boolean, selectedRows: TRecord[], changeRows: TRecord[]) => void
onSelectAll?: (selected: boolean, selectedRows: TRecord[], changeRows: TRecord[]) => void
onSelectInvert?: (selectedRowKeys: Key[]) => void
onSelectNone?: () => void
getCheckboxProps?: (record: TRecord) => { disabled?: boolean; name?: string }
columnWidth?: number | string
fixed?: boolean | 'left' | 'right'
columnTitle?: string | VNodeChild
renderCell?: (
value: boolean,
record: TRecord,
index: number,
originNode: VNodeChild,
) => VNodeChild | RenderedCell
checkStrictly?: boolean
selections?: boolean | (SelectionItem | SelectionSentinel)[]
hideSelectAll?: boolean
}export interface SelectionItem {
key: string
text: string | VNodeChild
onSelect?: (changeableRowKeys: Key[]) => void
}export interface Expandable<TRecord extends object = Record<string, any>> {
expandedRowRender?: (
record: TRecord,
index: number,
indent: number,
expanded: boolean,
) => VNodeChild
expandedRowKeys?: Key[]
defaultExpandedRowKeys?: Key[]
expandRowByClick?: boolean
expandIcon?: (props: {
expanded: boolean
record: TRecord
expandable: boolean
onExpand: (record: TRecord, e: Event) => void
}) => VNodeChild
onExpand?: (expanded: boolean, record: TRecord) => void
onExpandedRowsChange?: (expandedKeys: Key[]) => void
columnWidth?: number | string
fixed?: 'left' | 'right' | true
defaultExpandAllRows?: boolean
rowExpandable?: (record: TRecord) => boolean
showExpandColumn?: boolean
expandedRowClassName?: string | RowClassName<TRecord>
}Events and slots
export type TableFiltersInfo = Record<string, (string | number | boolean)[] | null>export interface SorterResultLike<TRecord extends object = Record<string, any>> {
column: ColumnType<TRecord> | undefined
columnKey: Key | undefined
order: SortOrder
field: ColumnType<TRecord>['dataIndex']
}export type VTableSorterResult<TRecord extends object = Record<string, any>> =
| SorterResultLike<TRecord>
| Array<SorterResultLike<TRecord>>export interface TableChangeExtra<TRecord extends object = Record<string, any>> {
action: 'sort' | 'filter' | 'select' | 'paginate'
/** Available only when pagination is enabled. */
pagination?: TablePaginationState
currentDataSource: TRecord[]
}export interface RowDragSortInfo {
draggedKey: Key
targetKey: Key
orderedKeys: Key[]
}export interface VTableEventProps<TRecord extends object = Record<string, any>> {
onChange?: (
filters: TableFiltersInfo,
sorter: VTableSorterResult<TRecord>,
extra: TableChangeExtra<TRecord>,
) => void
onResizeColumn?: (column: ColumnType<TRecord>, width: number) => void
onRowDragEnd?: (newData: TRecord[], info: RowDragSortInfo) => void
}export interface TableBodyCellSlotProps<TRecord extends object = Record<string, any>> {
text: unknown
record: TRecord
index: number
column: ColumnType<TRecord>
}export interface TableHeaderCellSlotProps<TRecord extends object = Record<string, any>> {
title: VNodeChild | undefined
column: ColumnType<TRecord> | ColumnGroupType<TRecord>
index: number
}export interface CustomFilterDropdownSlotProps<TRecord extends object = Record<string, any>> {
column: ColumnType<TRecord>
selectedKeys: (string | number | boolean)[]
setSelectedKeys: (keys: (string | number | boolean)[]) => void
confirm: (options?: { closeDropdown?: boolean }) => void
clearFilters: (options?: { confirm?: boolean; closeDropdown?: boolean }) => void
filters: ColumnFilterItem[]
visible: boolean
close: () => void
}export interface TableDataSlotProps<TRecord extends object = Record<string, any>> {
data: TRecord[]
}export interface TableSlotsDecl<TRecord extends object = Record<string, any>> {
bodyCell?: (props: TableBodyCellSlotProps<TRecord>) => VNodeChild
headerCell?: (props: TableHeaderCellSlotProps<TRecord>) => VNodeChild
empty?: () => VNodeChild
loading?: () => VNodeChild
customFilterDropdown?: (props: CustomFilterDropdownSlotProps<TRecord>) => VNodeChild
customFilterIcon?: (props: { column: ColumnType<TRecord>; filtered: boolean }) => VNodeChild
title?: (props: TableDataSlotProps<TRecord>) => VNodeChild
footer?: (props: TableDataSlotProps<TRecord>) => VNodeChild
paginationItem?: (props: TablePaginationSlotProps) => VNodeChild
summary?: () => VNodeChild
}Pagination
export interface TablePaginationConfig {
current?: number
defaultCurrent?: number
pageSize?: number
defaultPageSize?: number
total?: number
disabled?: boolean
hideOnSinglePage?: boolean
showSizeChanger?: boolean
pageSizeOptions?: (string | number)[]
totalBoundaryShowSizeChanger?: number
buildOptionText?: (option: { value: string | number }) => VNodeChild
showQuickJumper?: boolean | { goButton?: VNodeChild }
showTotal?: (total: number, range: [number, number]) => VNodeChild
size?: 'default' | 'small'
simple?: boolean
showLessItems?: boolean
pagerCount?: number
responsive?: boolean
itemRender?: (item: {
page: number
type: PaginationItemType
originalElement: VNodeChild
}) => VNodeChild
locale?: Partial<VTableGuildPaginationLocale>
class?: string
style?: CSSProperties
position?: TablePaginationPosition[]
layout?: TablePaginationLayout
onChange?: (page: number, pageSize: number) => void
onShowSizeChange?: (current: number, size: number) => void
'onUpdate:current'?: (current: number) => void
'onUpdate:pageSize'?: (pageSize: number) => void
}export interface TablePaginationState {
current: number
pageSize: number
total: number
}export type TablePaginationPosition =
| 'topLeft'
| 'topCenter'
| 'topRight'
| 'bottomLeft'
| 'bottomCenter'
| 'bottomRight'
| 'none'export type PaginationItemType = 'page' | 'prev' | 'next' | 'jump-prev' | 'jump-next'export type TablePaginationBuiltinLayoutItem =
| 'total'
| 'sizes'
| 'prev'
| 'pager'
| 'next'
| 'jumper'export type TablePaginationLayoutItem = TablePaginationBuiltinLayoutItem | { readonly slot: string }export type TablePaginationLayout =
| readonly TablePaginationLayoutItem[]
| {
readonly left?: readonly TablePaginationLayoutItem[]
readonly right?: readonly TablePaginationLayoutItem[]
}export type TablePaginationSlotProps = Readonly<
TablePaginationState & {
name: string
pageCount: number
range: readonly [number, number]
disabled: boolean
position: Exclude<TablePaginationPosition, 'none'>
region: 'inline' | 'left' | 'right'
}
>Summary components
export type SummaryFixed = boolean | 'top' | 'bottom'/** 文档说明用辅助接口,不是包导出。 */
export interface VTableSummaryProps {
fixed?: SummaryFixed
}/** 文档说明用辅助接口,不是包导出。index 是必填的列索引。 */
export interface VTableSummaryCellProps {
index: number
colSpan?: number
rowSpan?: number
align?: AlignType
}