From f45f0b43689a2ba16e3d182a21e878d1d1d1e294 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=80=E5=8F=AA=E5=89=8D=E7=AB=AF=E6=B1=AA?= <985313519@qq.com> Date: Thu, 25 Apr 2024 17:58:14 +0800 Subject: [PATCH] fix(components): [table] return type of function summary-method supports VNode (#16648) * fix(components): [table] return type of function summary-method * fix: type --- docs/en-US/component/table.md | 4 ++-- docs/examples/table/summary.vue | 8 ++++++-- packages/components/table/src/table/defaults.ts | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/docs/en-US/component/table.md b/docs/en-US/component/table.md index 1338c4a8e1..991f188816 100644 --- a/docs/en-US/component/table.md +++ b/docs/en-US/component/table.md @@ -193,7 +193,7 @@ table/tree-and-lazy For table of numbers, you can add an extra row at the table footer displaying each column's sum. -:::demo You can add the summary row by setting `show-summary` to `true`. By default, for the summary row, the first column does not sum anything up but always displays 'Sum' (you can configure the displayed text using `sum-text`), while other columns sum every number in that column up and display them. You can of course define your own sum behaviour. To do so, pass a method to `summary-method`, which returns an array, and each element of the returned array will be displayed in the columns of the summary row. The second table of this example is a detailed demo. +:::demo You can add the summary row by setting `show-summary` to `true`. By default, for the summary row, the first column does not sum anything up but always displays 'Sum' (you can configure the displayed text using `sum-text`), while other columns sum every number in that column up and display them. You can of course define your own sum behaviour. To do so, pass a method to `summary-method`, which returns an array, and each element of the returned array will be displayed in the columns of the summary row, It can be a VNode or string. The second table of this example is a detailed demo. table/summary @@ -262,7 +262,7 @@ table/table-layout | tooltip-options ^(2.2.28) | the options for the overflow tooltip, [see the following tooltip component](tooltip.html#attributes) | ^[object]`Pick` | ^[object]`{ enterable: true, placement: 'top', showArrow: true, hideAfter: 200, popperOptions: { strategy: 'fixed' } }` | | show-summary | whether to display a summary row | ^[boolean] | false | | sum-text | displayed text for the first column of summary row | ^[string] | Sum | -| summary-method | custom summary method | ^[Function]`(data: { columns: any[], data: any[] }) => string[]` | — | +| summary-method | custom summary method | ^[Function]`(data: { columns: any[], data: any[] }) => (VNode \| string)[]` | — | | span-method | method that returns rowspan and colspan | ^[Function]`(data: { row: any, column: any, rowIndex: number, columnIndex: number }) => number[] \| { rowspan: number, colspan: number } \| void` | — | | select-on-indeterminate | controls the behavior of master checkbox in multi-select tables when only some rows are selected (but not all). If true, all rows will be selected, else deselected | ^[boolean] | true | | indent | horizontal indentation of tree data | ^[number] | 16 | diff --git a/docs/examples/table/summary.vue b/docs/examples/table/summary.vue index d507026037..6fb28b3b93 100644 --- a/docs/examples/table/summary.vue +++ b/docs/examples/table/summary.vue @@ -24,6 +24,8 @@