import{ax as i,z as a,A as l,b5 as n}from"./chunks/framework.V2ssSR2R.js";const E=JSON.parse('{"title":"Table组件 events","description":"","frontmatter":{},"headers":[],"relativePath":"api/table/events.md","filePath":"api/table/events.md"}'),e={name:"api/table/events.md"};function t(h,s,k,p,r,d){return l(),a("div",null,[...s[0]||(s[0]=[n(`
参数:
{ column, prop, order } - 排序信息对象 column: Object - 排序的列配置prop: string - 排序的列属性名order: 'ascending' | 'descending' | null - 排序方式说明: 当表格的排序条件发生变化时触发
示例:
const handleSortChange = ({ column, prop, order }) => {
console.log('排序变化:', prop, order);
};参数:
payload: { index: number } - 触发动作所在行的索引说明: 表格行的编辑型动作(如 actions 中 type: 'edit' 的保存)执行结束后触发。
注意:ActionsColumn 在 handler 返回值为「假值」(如 undefined/null/未返回)时同样会派发该事件;仅当返回值为对象且 res.ret !== 0 时才视为失败、不派发。如果业务需要严格在「业务接口成功」后再处理,应在 handler 内显式 return { ret: 0 } 并在监听处自行判断 res.ret。
示例:
const handleAfterAction = ({ index }) => {
console.log('操作完成,行索引:', index);
};参数:
payload: { index: number } - 触发动作所在行的索引说明: 表格行的编辑型动作被取消后触发
示例:
const handleAfterActionCancel = ({ index }) => {
console.log('操作取消,行索引:', index);
};参数:
selection: Array<any> - 当前选中的行数据数组row: any - 刚刚被选中的行数据说明: 当用户手动勾选某一行时触发
示例:
const handleSelect = (selection, row) => {
console.log('选中行:', row);
console.log('当前选中:', selection);
};参数:
selection: Array<any> - 当前选中的行数据数组说明: 当用户手动勾选全选 Checkbox 时触发
示例:
const handleSelectAll = (selection) => {
console.log('全选/取消全选:', selection.length);
};参数:
selection: Array<any> - 当前选中的行数据数组说明: 当选择项发生变化时触发
示例:
const handleSelectionChange = (selection) => {
console.log('选中项变化:', selection);
};参数:
row: any - 被展开/收起的行数据expandedRows: Array<any> - 当前所有展开的行数据数组说明: 当用户展开或收起某一行时触发(用于可展开表格)
示例:
const handleExpandChange = (row, expandedRows) => {
console.log('展开状态变化:', row);
console.log('当前展开行:', expandedRows);
};参数:
row: any - 行数据column: Object - 列配置cell: HTMLElement - 单元格 DOM 元素event: Event - 原生事件对象说明: 当某个单元格被点击时触发
示例:
const handleCellClick = (row, column, cell, event) => {
console.log('单元格点击:', row, column.property);
};