A PC-end table component based on Vxe UI, supporting copy-paste, data pivot table, and high-performance virtual list table solution.
—
The VxeTable component is the foundational table implementation providing comprehensive data display, interaction, and customization capabilities with high-performance virtual scrolling.
Core table component with virtual scrolling and extensive configuration options.
/**
* Core table component for data display and interaction
*/
interface VxeTable extends ComponentPublicInstance {
// Basic configuration
data: Record<string, any>[];
height?: number | string;
minHeight?: number | string;
maxHeight?: number | string;
stripe?: boolean;
border?: boolean | string;
round?: boolean;
size?: VxeTablePropTypes.Size;
fit?: boolean;
loading?: boolean;
align?: VxeTablePropTypes.Align;
headerAlign?: VxeTablePropTypes.HeaderAlign;
footerAlign?: VxeTablePropTypes.FooterAlign;
showHeader?: boolean;
showFooter?: boolean;
// Display configuration
showOverflow?: VxeTablePropTypes.ShowOverflow;
showHeaderOverflow?: VxeTablePropTypes.ShowHeaderOverflow;
showFooterOverflow?: VxeTablePropTypes.ShowFooterOverflow;
emptyText?: string;
emptyRender?: VxeTablePropTypes.EmptyRender;
// Styling
rowClassName?: VxeTablePropTypes.RowClassName;
cellClassName?: VxeTablePropTypes.CellClassName;
headerRowClassName?: VxeTablePropTypes.HeaderRowClassName;
headerCellClassName?: VxeTablePropTypes.HeaderCellClassName;
footerRowClassName?: VxeTablePropTypes.FooterRowClassName;
footerCellClassName?: VxeTablePropTypes.FooterCellClassName;
rowStyle?: VxeTablePropTypes.RowStyle;
cellStyle?: VxeTablePropTypes.CellStyle;
headerRowStyle?: VxeTablePropTypes.HeaderRowStyle;
headerCellStyle?: VxeTablePropTypes.HeaderCellStyle;
footerRowStyle?: VxeTablePropTypes.FooterRowStyle;
footerCellStyle?: VxeTablePropTypes.FooterCellStyle;
// Advanced configuration objects
rowConfig?: VxeTablePropTypes.RowConfig;
columnConfig?: VxeTablePropTypes.ColumnConfig;
resizableConfig?: VxeTablePropTypes.ResizableConfig;
sortConfig?: VxeTablePropTypes.SortConfig;
filterConfig?: VxeTablePropTypes.FilterConfig;
radioConfig?: VxeTablePropTypes.RadioConfig;
checkboxConfig?: VxeTablePropTypes.CheckboxConfig;
tooltipConfig?: VxeTablePropTypes.TooltipConfig;
editConfig?: VxeTablePropTypes.EditConfig;
validConfig?: VxeTablePropTypes.ValidConfig;
editRules?: VxeTablePropTypes.EditRules;
expandConfig?: VxeTablePropTypes.ExpandConfig;
treeConfig?: VxeTablePropTypes.TreeConfig;
menuConfig?: VxeTablePropTypes.MenuConfig;
mouseConfig?: VxeTablePropTypes.MouseConfig;
areaConfig?: VxeTablePropTypes.AreaConfig;
keyboardConfig?: VxeTablePropTypes.KeyboardConfig;
clipConfig?: VxeTablePropTypes.ClipConfig;
fnrConfig?: VxeTablePropTypes.FnrConfig;
// Virtual scrolling
virtualXConfig?: VxeTablePropTypes.VirtualXConfig;
virtualYConfig?: VxeTablePropTypes.VirtualYConfig;
scrollbarConfig?: VxeTablePropTypes.ScrollbarConfig;
// Data management
footerData?: Record<string, any>[][];
keepSource?: boolean;
autoResize?: boolean;
syncResize?: boolean;
// Component methods
loadData(data: Record<string, any>[]): Promise<void>;
reloadData(data: Record<string, any>[]): Promise<void>;
updateData(): Promise<void>;
createData(records: Record<string, any>[]): Promise<void>;
createRow(records: Record<string, any> | Record<string, any>[]): Promise<void>;
revertData(rows?: any | any[], field?: string): Promise<void>;
clearAll(): Promise<void>;
syncData(): Promise<void>;
getTableData(): {
visibleData: Record<string, any>[];
fullData: Record<string, any>[];
tableData: Record<string, any>[];
};
clearData(): Promise<void>;
// Row operations
getRowNode(tr: HTMLElement): VxeTableDefines.RowInfo | null;
getRowById(rowid: string | number): any;
getRowid(row: any): string;
getRowIndex(row: any): number;
getVTRowIndex(row: any): number;
getVMRowIndex(row: any): number;
setRow(row: any, record: Record<string, any>): Promise<void>;
moveRowTo(rows: any | any[], targetRow: any): Promise<void>;
getCurrentRecord(): any;
setCurrentRow(row: any): Promise<void>;
clearCurrentRow(): Promise<void>;
// Column operations
getColumnById(colid: string): VxeTableDefines.ColumnInfo;
getColumnByField(field: string): VxeTableDefines.ColumnInfo;
getColumns(): VxeTableDefines.ColumnInfo[];
getVisibleColumns(): VxeTableDefines.ColumnInfo[];
loadColumn(columns: VxeColumnDefines.ColumnOptions[]): Promise<void>;
reloadColumn(columns: VxeColumnDefines.ColumnOptions[]): Promise<void>;
setColumnFixed(fieldOrColumn: string | VxeTableDefines.ColumnInfo, fixed: VxeColumnPropTypes.Fixed): Promise<void>;
setColumnWidth(fieldOrColumn: string | VxeTableDefines.ColumnInfo, width: number | string): Promise<void>;
hideColumn(fieldOrColumn: string | VxeTableDefines.ColumnInfo): Promise<void>;
showColumn(fieldOrColumn: string | VxeTableDefines.ColumnInfo): Promise<void>;
refreshColumn(): Promise<void>;
getCurrentColumn(): VxeTableDefines.ColumnInfo;
setCurrentColumn(fieldOrColumn: string | VxeTableDefines.ColumnInfo): Promise<void>;
clearCurrentColumn(): Promise<void>;
// Selection operations
getRadioRecord(): any;
setRadioRow(row: any): Promise<void>;
clearRadioRow(): Promise<void>;
isCheckedByRadioRow(row: any): boolean;
getCheckboxRecords(): Record<string, any>[];
setCheckboxRow(rows: Record<string, any>[], checked: boolean): Promise<void>;
toggleCheckboxRow(row: any): Promise<void>;
setAllCheckboxRow(checked: boolean): Promise<void>;
clearCheckboxRow(): Promise<void>;
isCheckedByCheckboxRow(row: any): boolean;
// Sorting
sort(sortConfs: VxeTableDefines.SortCheckedParams[]): Promise<void>;
clearSort(): Promise<void>;
getSortColumns(): VxeTableDefines.SortCheckedParams[];
// Filtering
filter(filters: VxeTableDefines.FilterCheckedParams[]): Promise<void>;
clearFilter(fieldOrColumn?: string | VxeTableDefines.ColumnInfo): Promise<void>;
closeFilter(): Promise<void>;
clearFilterByEvent(): Promise<void>;
isActiveFilterByColumn(fieldOrColumn: string | VxeTableDefines.ColumnInfo): boolean;
// Cell operations
getCellElement(row: any, fieldOrColumn: string | VxeTableDefines.ColumnInfo): HTMLElement;
focus(): Promise<void>;
blur(): Promise<void>;
// Export/Import
exportData(options?: VxeTablePropTypes.ExportConfig): Promise<void>;
openImport(options?: VxeTablePropTypes.ImportConfig): Promise<void>;
// Tree operations
setTreeExpand(rows: any[], expanded: boolean): Promise<void>;
setAllTreeExpand(expanded: boolean): Promise<void>;
toggleTreeExpand(row: any): Promise<void>;
clearTreeExpand(): Promise<void>;
isTreeExpandByRow(row: any): boolean;
getTreeExpandRecords(): any[];
loadTreeChildren(row: any, childRecords: any[]): Promise<void>;
// Row expansion
setRowExpand(rows: any[], expanded: boolean): Promise<void>;
setAllRowExpand(expanded: boolean): Promise<void>;
toggleRowExpand(row: any): Promise<void>;
clearRowExpand(): Promise<void>;
isRowExpandByRow(row: any): boolean;
getRowExpandRecords(): any[];
// Scrolling operations
getScroll(): VxeTableDefines.ScrollInfo;
scrollTo(scrollLeft: number, scrollTop?: number): Promise<void>;
scrollToRow(row: any, fieldOrColumn?: string | VxeTableDefines.ColumnInfo): Promise<void>;
scrollToColumn(fieldOrColumn: string | VxeTableDefines.ColumnInfo): Promise<void>;
clearScroll(): Promise<void>;
// Cell merging
setMergeCells(merges: VxeTableDefines.MergeOptions[]): Promise<void>;
removeMergeCells(merges: VxeTableDefines.MergeOptions[]): Promise<void>;
getMergeCells(): VxeTableDefines.MergeInfo[];
clearMergeCells(): Promise<void>;
// Layout and sizing
recalculate(): Promise<void>;
refreshScroll(): Promise<void>;
updateFooter(): Promise<void>;
setRowHeight(rows: any[], height: number | string): Promise<void>;
// Toolbar integration
connectToolbar($toolbar: VxeToolbarInstance): Promise<void>;
}Essential properties for table setup and data display.
interface BasicTableProps {
/** Table data array */
data?: Record<string, any>[];
/** Table height (number for pixels, string for CSS values) */
height?: number | string;
/** Minimum table height */
minHeight?: number | string;
/** Maximum table height */
maxHeight?: number | string;
/** Enable row striping */
stripe?: boolean;
/** Border style ('default' | 'full' | 'outer' | 'inner' | 'none') */
border?: boolean | string;
/** Round corners */
round?: boolean;
/** Component size */
size?: 'mini' | 'small' | 'medium' | 'large';
/** Auto fit container width */
fit?: boolean;
/** Loading state */
loading?: boolean;
/** Cell content alignment */
align?: 'left' | 'center' | 'right';
/** Header alignment */
headerAlign?: 'left' | 'center' | 'right';
/** Footer alignment */
footerAlign?: 'left' | 'center' | 'right';
/** Show table header */
showHeader?: boolean;
/** Show table footer */
showFooter?: boolean;
}High-performance virtual scrolling for large datasets.
interface VirtualScrollConfig {
/** Horizontal virtual scrolling configuration */
virtualXConfig?: {
/** Enable horizontal virtual scrolling */
enabled?: boolean;
/** Threshold to trigger virtual scrolling */
gt?: number;
/** Pre-render size */
preSize?: number;
/** Buffer size */
oSize?: number;
};
/** Vertical virtual scrolling configuration */
virtualYConfig?: {
/** Enable vertical virtual scrolling */
enabled?: boolean;
/** Scroll mode ('wheel' | 'native') */
mode?: string;
/** Threshold to trigger virtual scrolling */
gt?: number;
/** Pre-render size */
preSize?: number;
/** Buffer size */
oSize?: number;
};
/** Scrollbar configuration */
scrollbarConfig?: {
/** Horizontal scrollbar */
x?: {
/** Position ('top' | 'bottom') */
position?: string;
/** Visibility */
visible?: boolean;
};
/** Vertical scrollbar */
y?: {
/** Position ('left' | 'right') */
position?: string;
/** Visibility */
visible?: boolean;
};
};
}Advanced row and column behavior configuration.
interface RowColumnConfig {
/** Row configuration */
rowConfig?: {
/** Row key field for tracking */
keyField?: string;
/** Use key for performance optimization */
useKey?: boolean;
/** Resizable rows */
resizable?: boolean;
/** Row height */
height?: number | string;
};
/** Column configuration */
columnConfig?: {
/** Resizable columns */
resizable?: boolean;
/** Use key for performance optimization */
useKey?: boolean;
/** Width calculation mode */
width?: 'auto' | number;
/** Minimum column width */
minWidth?: number;
/** Maximum fixed columns */
maxFixedSize?: number;
};
/** Column resizing configuration */
resizableConfig?: {
/** Drag mode ('auto' | 'manual') */
dragMode?: string;
/** Show drag tip */
showDragTip?: boolean;
/** Sync auto height */
isSyncAutoHeight?: boolean;
/** Sync auto width */
isSyncAutoWidth?: boolean;
/** Minimum height */
minHeight?: number;
};
}Usage Examples:
// Basic table setup
<VxeTable
:data="tableData"
border
stripe
height="400"
:virtual-y-config="{ enabled: true, gt: 100 }"
>
<VxeColumn field="id" title="ID" width="80"></VxeColumn>
<VxeColumn field="name" title="Name" min-width="120"></VxeColumn>
<VxeColumn field="age" title="Age" width="80"></VxeColumn>
</VxeTable>
// Virtual scrolling for large datasets
<VxeTable
:data="largeDataset"
:virtual-x-config="{ enabled: true, gt: 20 }"
:virtual-y-config="{ enabled: true, gt: 100 }"
:scroll-y="{ enabled: true, gt: 100 }"
height="600"
>
<!-- columns -->
</VxeTable>
// Programmatic API usage
const tableRef = ref<VxeTableInstance>();
// Load data
await tableRef.value?.loadData(newData);
// Get current selection
const currentRow = tableRef.value?.getCurrentRecord();
// Scroll to specific row
await tableRef.value?.scrollToRow(targetRow);VxeTable provides comprehensive event coverage for all user interactions and data operations.
interface VxeTableEvents {
// Data events
'update:data': (data: any[]) => void;
'data-change': (params: VxeTableDefines.DataChangeEventParams) => void;
'footer-data-change': (params: VxeTableDefines.FooterDataChangeEventParams) => void;
// Cell events
'cell-click': (params: VxeTableDefines.CellClickEventParams) => void;
'cell-dblclick': (params: VxeTableDefines.CellDblclickEventParams) => void;
'cell-menu': (params: VxeTableDefines.CellMenuEventParams) => void;
'cell-mouseenter': (params: VxeTableDefines.CellMouseenterEventParams) => void;
'cell-mouseleave': (params: VxeTableDefines.CellMouseleaveEventParams) => void;
// Header events
'header-cell-click': (params: VxeTableDefines.HeaderCellClickEventParams) => void;
'header-cell-dblclick': (params: VxeTableDefines.HeaderCellDblclickEventParams) => void;
'header-cell-menu': (params: VxeTableDefines.HeaderCellMenuEventParams) => void;
// Footer events
'footer-cell-click': (params: VxeTableDefines.FooterCellClickEventParams) => void;
'footer-cell-dblclick': (params: VxeTableDefines.FooterCellDblclickEventParams) => void;
'footer-cell-menu': (params: VxeTableDefines.FooterCellMenuEventParams) => void;
// Row selection events
'current-row-change': (params: VxeTableDefines.CurrentRowChangeEventParams) => void;
'current-column-change': (params: VxeTableDefines.CurrentColumnChangeEventParams) => void;
'radio-change': (params: VxeTableDefines.RadioChangeEventParams) => void;
'checkbox-change': (params: VxeTableDefines.CheckboxChangeEventParams) => void;
'checkbox-all': (params: VxeTableDefines.CheckboxAllEventParams) => void;
'checkbox-range-start': (params: VxeTableDefines.CheckboxRangeStartEventParams) => void;
'checkbox-range-change': (params: VxeTableDefines.CheckboxRangeChangeEventParams) => void;
'checkbox-range-end': (params: VxeTableDefines.CheckboxRangeEndEventParams) => void;
// Edit events
'edit-activated': (params: VxeTableDefines.EditActivatedEventParams) => void;
'edit-disabled': (params: VxeTableDefines.EditDisabledEventParams) => void;
'edit-closed': (params: VxeTableDefines.EditClosedEventParams) => void;
'valid-error': (params: VxeTableDefines.ValidErrorEventParams) => void;
// Sort and filter events
'sort-change': (params: VxeTableDefines.SortChangeEventParams) => void;
'clear-sort': (params: VxeTableDefines.ClearSortEventParams) => void;
'filter-change': (params: VxeTableDefines.FilterChangeEventParams) => void;
'clear-filter': (params: VxeTableDefines.ClearFilterEventParams) => void;
// Tree structure events
'toggle-tree-expand': (params: VxeTableDefines.ToggleTreeExpandEventParams) => void;
'toggle-row-expand': (params: VxeTableDefines.ToggleRowExpandEventParams) => void;
// Scroll events
'scroll': (params: VxeTableDefines.ScrollEventParams) => void;
'scroll-start': (params: VxeTableDefines.ScrollStartEventParams) => void;
'scroll-end': (params: VxeTableDefines.ScrollEndEventParams) => void;
'scroll-boundary': (params: VxeTableDefines.ScrollBoundaryEventParams) => void;
// Area selection and clipboard events
'cell-area-selection-start': (params: VxeTableDefines.CellAreaSelectionStartEventParams) => void;
'cell-area-selection-drag': (params: VxeTableDefines.CellAreaSelectionDragEventParams) => void;
'cell-area-selection-end': (params: VxeTableDefines.CellAreaSelectionEndEventParams) => void;
'cell-area-copy': (params: VxeTableDefines.CellAreaCopyEventParams) => void;
'cell-area-cut': (params: VxeTableDefines.CellAreaCutEventParams) => void;
'cell-area-paste': (params: VxeTableDefines.CellAreaPasteEventParams) => void;
// Drag and drop events
'row-dragstart': (params: VxeTableDefines.RowDragstartEventParams) => void;
'row-dragover': (params: VxeTableDefines.RowDragoverEventParams) => void;
'row-dragend': (params: VxeTableDefines.RowDragendEventParams) => void;
'column-dragstart': (params: VxeTableDefines.ColumnDragstartEventParams) => void;
'column-dragover': (params: VxeTableDefines.ColumnDragoverEventParams) => void;
'column-dragend': (params: VxeTableDefines.ColumnDragendEventParams) => void;
// Keyboard events
'keydown-start': (params: VxeTableDefines.KeydownStartEventParams) => void;
'keydown': (params: VxeTableDefines.KeydownEventParams) => void;
'keydown-end': (params: VxeTableDefines.KeydownEndEventParams) => void;
// Context menu events
'menu-click': (params: VxeTableDefines.MenuClickEventParams) => void;
// Resize events
'column-resizable': (params: VxeTableDefines.ColumnResizableEventParams) => void;
'column-resizable-change': (params: VxeTableDefines.ColumnResizableChangeEventParams) => void;
}// Table size options
type VxeTablePropTypes.Size = 'mini' | 'small' | 'medium' | 'large';
// Alignment options
type VxeTablePropTypes.Align = 'left' | 'center' | 'right';
// Overflow display options
type VxeTablePropTypes.ShowOverflow = boolean | 'ellipsis' | 'title' | 'tooltip';
// Row/cell styling function types
type VxeTablePropTypes.RowClassName = string | ((params: any) => string);
type VxeTablePropTypes.CellClassName = string | ((params: any) => string);
type VxeTablePropTypes.RowStyle = object | ((params: any) => object);
type VxeTablePropTypes.CellStyle = object | ((params: any) => object);
// Row and scroll information types
interface VxeTableDefines.RowInfo {
$seq: number;
seq: number;
rowIndex: number;
$rowIndex: number;
_rowIndex: number;
index: number;
$index: number;
_index: number;
row: any;
rowKey: string | number;
level: number;
parent: any;
children?: any[];
height: number;
top: number;
[key: string]: any;
}
interface VxeTableDefines.ScrollInfo {
virtualX: boolean;
virtualY: boolean;
scrollTop: number;
scrollLeft: number;
bodyWidth: number;
bodyHeight: number;
isScrollX: boolean;
isScrollY: boolean;
}
// Merge operation types
interface VxeTableDefines.MergeOptions {
row: any;
column: VxeColumnDefines.ColumnInfo;
rowspan?: number;
colspan?: number;
}
interface VxeTableDefines.MergeInfo {
row: any;
column: VxeColumnDefines.ColumnInfo;
rowspan: number;
colspan: number;
}
// Sort and filter parameter types
interface VxeTableDefines.SortCheckedParams {
column: VxeColumnDefines.ColumnInfo;
field: string;
order: 'asc' | 'desc' | null;
}
interface VxeTableDefines.FilterCheckedParams {
column: VxeColumnDefines.ColumnInfo;
field: string;
values: any[];
datas: any[];
}
// Column options for dynamic columns
interface VxeColumnDefines.ColumnOptions {
field?: string;
title?: string;
width?: number | string;
minWidth?: number | string;
maxWidth?: number | string;
type?: VxeColumnPropTypes.Type;
fixed?: VxeColumnPropTypes.Fixed;
align?: VxeColumnPropTypes.Align;
headerAlign?: VxeColumnPropTypes.HeaderAlign;
showOverflow?: VxeColumnPropTypes.ShowOverflow;
[key: string]: any;
}
// Event parameter types
interface VxeTableDefines.DataChangeEventParams {
type: string;
$event: Event;
}
interface VxeTableDefines.CellClickEventParams {
row: any;
rowIndex: number;
column: VxeColumnDefines.ColumnInfo;
columnIndex: number;
cell: HTMLElement;
triggerRadio: boolean;
triggerCheckbox: boolean;
triggerTreeNode: boolean;
triggerExpandNode: boolean;
$event: MouseEvent;
}
interface VxeTableDefines.CurrentRowChangeEventParams {
row: any;
rowIndex: number;
$event: Event;
}
interface VxeTableDefines.RadioChangeEventParams {
row: any;
rowIndex: number;
$event: Event;
}
interface VxeTableDefines.CheckboxChangeEventParams {
records: any[];
reserves: any[];
indeterminates: any[];
checked: boolean;
$event: Event;
}
interface VxeTableDefines.EditActivatedEventParams {
row: any;
rowIndex: number;
column: VxeColumnDefines.ColumnInfo;
columnIndex: number;
cell: HTMLElement;
$event: Event;
}
interface VxeTableDefines.ValidErrorEventParams {
row: any;
column: VxeColumnDefines.ColumnInfo;
cell: HTMLElement;
rule: any;
rules: any[];
$event: Event;
}
interface VxeTableDefines.SortChangeEventParams {
column: VxeColumnDefines.ColumnInfo;
field: string;
property: string;
order: 'asc' | 'desc' | null;
sortBy: string;
sortTime: number;
$event: Event;
}
interface VxeTableDefines.FilterChangeEventParams {
column: VxeColumnDefines.ColumnInfo;
field: string;
property: string;
values: any[];
datas: any[];
filters: any[];
filterTime: number;
$event: Event;
}
interface VxeTableDefines.ScrollEventParams {
type: string;
fixed: VxeColumnPropTypes.Fixed;
scrollTop: number;
scrollLeft: number;
isX: boolean;
isY: boolean;
$event: Event;
}
interface VxeTableDefines.ToggleTreeExpandEventParams {
row: any;
rowIndex: number;
column: VxeColumnDefines.ColumnInfo;
columnIndex: number;
$event: Event;
}
interface VxeTableDefines.MenuClickEventParams {
menu: any;
type: string;
row?: any;
rowIndex?: number;
column?: VxeColumnDefines.ColumnInfo;
columnIndex?: number;
$event: Event;
}
// Table instance type
interface VxeTableInstance extends ComponentPublicInstance, VxeTable {}Install with Tessl CLI
npx tessl i tessl/npm-vxe-table