From 443640effa0818034f6c094704e8d5fde912e366 Mon Sep 17 00:00:00 2001 From: tangjinzhou <415800467@qq.com> Date: Fri, 17 Dec 2021 21:23:56 +0800 Subject: [PATCH] feat: customCell add column arg, close #5052 --- components/table/index.en-US.md | 2 +- components/table/index.zh-CN.md | 2 +- components/vc-table/Body/BodyRow.tsx | 2 +- components/vc-table/interface.ts | 1 + 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/components/table/index.en-US.md b/components/table/index.en-US.md index a4122547f..604beb302 100644 --- a/components/table/index.en-US.md +++ b/components/table/index.en-US.md @@ -179,7 +179,7 @@ One of the Table `columns` prop for describing the table's columns, Column has t | maxWidth | Drag the maximum width of the column, it will be affected by the automatic adjustment and distribution of the table width | number | - | 3.0 | | resizable | Whether the width can be adjusted by dragging, at this time width must be number type | boolean | - | 3.0 | | width | Width of this column | string\|number | - | | -| customCell | Set props on per cell | Function(record, rowIndex) | - | | +| customCell | Set props on per cell | Function(record, rowIndex, column) | - | column add from 3.0 | | customHeaderCell | Set props on per header cell | Function(column) | - | | | onFilter | Callback executed when the confirm filter button is clicked, Use as a `filter` event when using template or jsx | Function | - | | | onFilterDropdownVisibleChange | Callback executed when `filterDropdownVisible` is changed, Use as a `filterDropdownVisible` event when using template or jsx | function(visible) {} | - | | diff --git a/components/table/index.zh-CN.md b/components/table/index.zh-CN.md index 0e80cc1ae..1560f91f4 100644 --- a/components/table/index.zh-CN.md +++ b/components/table/index.zh-CN.md @@ -185,7 +185,7 @@ cover: https://gw.alipayobjects.com/zos/alicdn/f-SbcX2Lx/Table.svg | minWidth | 拖动列最小宽度,会受到表格自动调整分配宽度影响 | number | 50 | 3.0 | | maxWidth | 拖动列最大宽度,会受到表格自动调整分配宽度影响 | number | - | 3.0 | | resizable | 是否可拖动调整宽度,此时 width 必须是 number 类型 | boolean | - | 3.0 | -| customCell | 设置单元格属性 | Function(record, rowIndex) | - | | +| customCell | 设置单元格属性 | Function(record, rowIndex, column) | - | column add from 3.0 | | customHeaderCell | 设置头部单元格属性 | Function(column) | - | | | onFilter | 本地模式下,确定筛选的运行函数, 使用 template 或 jsx 时作为`filter`事件使用 | Function | - | | | onFilterDropdownVisibleChange | 自定义筛选菜单可见变化时调用,使用 template 或 jsx 时作为`filterDropdownVisibleChange`事件使用 | function(visible) {} | - | | diff --git a/components/vc-table/Body/BodyRow.tsx b/components/vc-table/Body/BodyRow.tsx index 79c69d675..d3ee09ed0 100644 --- a/components/vc-table/Body/BodyRow.tsx +++ b/components/vc-table/Body/BodyRow.tsx @@ -145,7 +145,7 @@ export default defineComponent>({ let additionalCellProps; if (column.customCell) { - additionalCellProps = column.customCell(record, index); + additionalCellProps = column.customCell(record, index, column); } return ( diff --git a/components/vc-table/interface.ts b/components/vc-table/interface.ts index e40200b84..27325249d 100644 --- a/components/vc-table/interface.ts +++ b/components/vc-table/interface.ts @@ -136,6 +136,7 @@ export interface StickyOffsets { export type GetComponentProps = ( data: DataType, index?: number, + column?: ColumnType, ) => Omit & { style?: CSSProperties }; type Component

= DefineComponent

| FunctionalComponent

| string;