From 19a2885cb3f9af52290b2491e642afa7f38e1313 Mon Sep 17 00:00:00 2001 From: Artea Date: Sun, 5 Jan 2025 10:45:12 +0800 Subject: [PATCH 01/15] docs(data-table): merge-cell ts demo Signed-off-by: Artea --- src/data-table/demos/enUS/index.demo-entry.md | 2 +- ...merge-cell.demo.md => merge-cell.demo.vue} | 56 +++++++++++++------ src/data-table/demos/zhCN/index.demo-entry.md | 2 +- ...merge-cell.demo.md => merge-cell.demo.vue} | 54 ++++++++++++------ 4 files changed, 76 insertions(+), 38 deletions(-) rename src/data-table/demos/enUS/{merge-cell.demo.md => merge-cell.demo.vue} (73%) rename src/data-table/demos/zhCN/{merge-cell.demo.md => merge-cell.demo.vue} (75%) diff --git a/src/data-table/demos/enUS/index.demo-entry.md b/src/data-table/demos/enUS/index.demo-entry.md index 87a34fcdc1b..2bb2edbf662 100644 --- a/src/data-table/demos/enUS/index.demo-entry.md +++ b/src/data-table/demos/enUS/index.demo-entry.md @@ -26,7 +26,7 @@ empty.vue border.vue size.vue row-props.vue -merge-cell +merge-cell.vue filter-and-sorter pagination-behavior-on-filter.vue multiple-sorter diff --git a/src/data-table/demos/enUS/merge-cell.demo.md b/src/data-table/demos/enUS/merge-cell.demo.vue similarity index 73% rename from src/data-table/demos/enUS/merge-cell.demo.md rename to src/data-table/demos/enUS/merge-cell.demo.vue index 035d8f11cc6..ebae2217def 100644 --- a/src/data-table/demos/enUS/merge-cell.demo.md +++ b/src/data-table/demos/enUS/merge-cell.demo.vue @@ -1,24 +1,35 @@ + # Merge cell Set colspan and rowspan by setting `colSpan` and `rowSpan` of column object. Set colspan in header by setting `titleColSpan` of column object. + -```html - -``` - -```js + + + diff --git a/src/data-table/demos/zhCN/index.demo-entry.md b/src/data-table/demos/zhCN/index.demo-entry.md index 73978e01842..cc338965178 100644 --- a/src/data-table/demos/zhCN/index.demo-entry.md +++ b/src/data-table/demos/zhCN/index.demo-entry.md @@ -28,7 +28,7 @@ empty.vue border.vue size.vue row-props.vue -merge-cell +merge-cell.vue filter-and-sorter pagination-behavior-on-filter.vue multiple-sorter diff --git a/src/data-table/demos/zhCN/merge-cell.demo.md b/src/data-table/demos/zhCN/merge-cell.demo.vue similarity index 75% rename from src/data-table/demos/zhCN/merge-cell.demo.md rename to src/data-table/demos/zhCN/merge-cell.demo.vue index 8f9afebe4d4..6a74c1731c5 100644 --- a/src/data-table/demos/zhCN/merge-cell.demo.md +++ b/src/data-table/demos/zhCN/merge-cell.demo.vue @@ -1,21 +1,31 @@ + # 合并单元格 设定列的 `colSpan` 和 `rowSpan` 来控制单元格的 `colspan` 和 `rowspan`。设定列的 `titleColSpan` 控制表头的 colspan。 + -```html - -``` - -```js + + + From 049d4d46a34a8f9df84885c0ef9888961db05e24 Mon Sep 17 00:00:00 2001 From: Artea Date: Sun, 5 Jan 2025 15:29:02 +0800 Subject: [PATCH 02/15] docs(data-table): render-header ts demo Signed-off-by: Artea --- src/data-table/demos/enUS/index.demo-entry.md | 2 +- src/data-table/demos/enUS/merge-cell.demo.vue | 10 ++--- ...-header.demo.md => render-header.demo.vue} | 40 +++++++++++++------ src/data-table/demos/zhCN/index.demo-entry.md | 2 +- src/data-table/demos/zhCN/merge-cell.demo.vue | 10 ++--- ...-header.demo.md => render-header.demo.vue} | 40 +++++++++++++------ 6 files changed, 66 insertions(+), 38 deletions(-) rename src/data-table/demos/enUS/{render-header.demo.md => render-header.demo.vue} (60%) rename src/data-table/demos/zhCN/{render-header.demo.md => render-header.demo.vue} (59%) diff --git a/src/data-table/demos/enUS/index.demo-entry.md b/src/data-table/demos/enUS/index.demo-entry.md index 2bb2edbf662..31b33e6f975 100644 --- a/src/data-table/demos/enUS/index.demo-entry.md +++ b/src/data-table/demos/enUS/index.demo-entry.md @@ -45,7 +45,7 @@ summary.vue ellipsis.vue ellipsis-tooltip.vue expand.vue -render-header +render-header.vue custom-style.vue ajax-usage virtual.vue diff --git a/src/data-table/demos/enUS/merge-cell.demo.vue b/src/data-table/demos/enUS/merge-cell.demo.vue index ebae2217def..f4b3bc59957 100644 --- a/src/data-table/demos/enUS/merge-cell.demo.vue +++ b/src/data-table/demos/enUS/merge-cell.demo.vue @@ -9,7 +9,7 @@ import type { DataTableColumns } from 'naive-ui' import { NButton, NTag, useMessage } from 'naive-ui' import { defineComponent, h } from 'vue' -interface RawData { +interface RowData { key: number name: string age: number @@ -18,14 +18,14 @@ interface RawData { } interface SendMail { - (rowData: RawData): void + (rowData: RowData): void } function createColumns({ sendMail }: { sendMail: SendMail -}): DataTableColumns { +}): DataTableColumns { return [ { title: 'Name', @@ -84,7 +84,7 @@ function createColumns({ ] } -function createData(): RawData[] { +function createData(): RowData[] { return [ { key: 0, @@ -113,7 +113,7 @@ function createData(): RawData[] { export default defineComponent({ setup() { const message = useMessage() - function sendMail(rowData: RawData) { + function sendMail(rowData: RowData) { message.info(`send mail to ${rowData.name}`) } return { diff --git a/src/data-table/demos/enUS/render-header.demo.md b/src/data-table/demos/enUS/render-header.demo.vue similarity index 60% rename from src/data-table/demos/enUS/render-header.demo.md rename to src/data-table/demos/enUS/render-header.demo.vue index 27cf20c692c..6dc5796deda 100644 --- a/src/data-table/demos/enUS/render-header.demo.md +++ b/src/data-table/demos/enUS/render-header.demo.vue @@ -1,25 +1,34 @@ + # Customized column header rendering + -```html - -``` - -```js + + + diff --git a/src/data-table/demos/zhCN/index.demo-entry.md b/src/data-table/demos/zhCN/index.demo-entry.md index cc338965178..24dea2407f7 100644 --- a/src/data-table/demos/zhCN/index.demo-entry.md +++ b/src/data-table/demos/zhCN/index.demo-entry.md @@ -47,7 +47,7 @@ summary.vue ellipsis.vue ellipsis-tooltip.vue expand.vue -render-header +render-header.vue custom-style.vue ajax-usage virtual.vue diff --git a/src/data-table/demos/zhCN/merge-cell.demo.vue b/src/data-table/demos/zhCN/merge-cell.demo.vue index 6a74c1731c5..4fc027590ba 100644 --- a/src/data-table/demos/zhCN/merge-cell.demo.vue +++ b/src/data-table/demos/zhCN/merge-cell.demo.vue @@ -9,7 +9,7 @@ import type { DataTableColumns } from 'naive-ui' import { NButton, NTag, useMessage } from 'naive-ui' import { defineComponent, h } from 'vue' -interface RawData { +interface RowData { key: number name: string age: number @@ -18,14 +18,14 @@ interface RawData { } interface SendMail { - (rowData: RawData): void + (rowData: RowData): void } function createColumns({ sendMail }: { sendMail: SendMail -}): DataTableColumns { +}): DataTableColumns { return [ { title: 'Name', @@ -84,7 +84,7 @@ function createColumns({ ] } -function createData(): RawData[] { +function createData(): RowData[] { return [ { key: 0, @@ -113,7 +113,7 @@ function createData(): RawData[] { export default defineComponent({ setup() { const message = useMessage() - function sendMail(rowData: RawData) { + function sendMail(rowData: RowData) { message.info(`send mail to ${rowData.name}`) } return { diff --git a/src/data-table/demos/zhCN/render-header.demo.md b/src/data-table/demos/zhCN/render-header.demo.vue similarity index 59% rename from src/data-table/demos/zhCN/render-header.demo.md rename to src/data-table/demos/zhCN/render-header.demo.vue index ad6e984ca79..f5af0063ba2 100644 --- a/src/data-table/demos/zhCN/render-header.demo.md +++ b/src/data-table/demos/zhCN/render-header.demo.vue @@ -1,25 +1,34 @@ + # 自定义渲染列头 + -```html - -``` - -```js + + + From 923a5d924f169ea867aa2440b208bf06d4baea18 Mon Sep 17 00:00:00 2001 From: Artea Date: Sun, 5 Jan 2025 16:48:49 +0800 Subject: [PATCH 03/15] docs(data-table): switchable-editable ts demo Signed-off-by: Artea --- src/data-table/demos/enUS/index.demo-entry.md | 2 +- ...e.demo.md => switchable-editable.demo.vue} | 72 +++++++++++-------- src/data-table/demos/zhCN/index.demo-entry.md | 2 +- ...e.demo.md => switchable-editable.demo.vue} | 69 +++++++++++------- 4 files changed, 87 insertions(+), 58 deletions(-) rename src/data-table/demos/enUS/{switchable-editable.demo.md => switchable-editable.demo.vue} (67%) rename src/data-table/demos/zhCN/{switchable-editable.demo.md => switchable-editable.demo.vue} (67%) diff --git a/src/data-table/demos/enUS/index.demo-entry.md b/src/data-table/demos/enUS/index.demo-entry.md index 31b33e6f975..4fba767196b 100644 --- a/src/data-table/demos/enUS/index.demo-entry.md +++ b/src/data-table/demos/enUS/index.demo-entry.md @@ -55,7 +55,7 @@ tree.vue flex-height.vue striped.vue simple-editable.vue -switchable-editable +switchable-editable.vue context-menu.vue async-expand.vue render-cell.vue diff --git a/src/data-table/demos/enUS/switchable-editable.demo.md b/src/data-table/demos/enUS/switchable-editable.demo.vue similarity index 67% rename from src/data-table/demos/enUS/switchable-editable.demo.md rename to src/data-table/demos/enUS/switchable-editable.demo.vue index 21e4afbf669..5a9b615ba2f 100644 --- a/src/data-table/demos/enUS/switchable-editable.demo.md +++ b/src/data-table/demos/enUS/switchable-editable.demo.vue @@ -1,20 +1,25 @@ + # Switchable Editable Table + -```html - -``` - -```js + + + diff --git a/src/data-table/demos/zhCN/index.demo-entry.md b/src/data-table/demos/zhCN/index.demo-entry.md index 24dea2407f7..f25af678ec4 100644 --- a/src/data-table/demos/zhCN/index.demo-entry.md +++ b/src/data-table/demos/zhCN/index.demo-entry.md @@ -57,7 +57,7 @@ tree.vue flex-height.vue striped.vue simple-editable.vue -switchable-editable +switchable-editable.vue context-menu.vue async-expand.vue render-cell.vue diff --git a/src/data-table/demos/zhCN/switchable-editable.demo.md b/src/data-table/demos/zhCN/switchable-editable.demo.vue similarity index 67% rename from src/data-table/demos/zhCN/switchable-editable.demo.md rename to src/data-table/demos/zhCN/switchable-editable.demo.vue index 5531dcb092f..39751f22ec0 100644 --- a/src/data-table/demos/zhCN/switchable-editable.demo.md +++ b/src/data-table/demos/zhCN/switchable-editable.demo.vue @@ -1,20 +1,25 @@ + # 可切换的可编辑表格 + -```html - -``` - -```js + + + From 4ec15e44a5b465938b398fca240813ed1ef8708e Mon Sep 17 00:00:00 2001 From: Artea Date: Mon, 13 Jan 2025 02:09:38 +0800 Subject: [PATCH 04/15] docs(data-table): controlled-mutiple-sorter ts demo Signed-off-by: Artea --- ...md => controlled-multiple-sorter.demo.vue} | 67 +++++++++++++------ src/data-table/demos/enUS/index.demo-entry.md | 2 +- ...md => controlled-multiple-sorter.demo.vue} | 67 +++++++++++++------ src/data-table/demos/zhCN/index.demo-entry.md | 2 +- 4 files changed, 94 insertions(+), 44 deletions(-) rename src/data-table/demos/enUS/{controlled-multiple-sorter.demo.md => controlled-multiple-sorter.demo.vue} (64%) rename src/data-table/demos/zhCN/{controlled-multiple-sorter.demo.md => controlled-multiple-sorter.demo.vue} (64%) diff --git a/src/data-table/demos/enUS/controlled-multiple-sorter.demo.md b/src/data-table/demos/enUS/controlled-multiple-sorter.demo.vue similarity index 64% rename from src/data-table/demos/enUS/controlled-multiple-sorter.demo.md rename to src/data-table/demos/enUS/controlled-multiple-sorter.demo.vue index 1a3b6a3b932..164a81cbe7b 100644 --- a/src/data-table/demos/enUS/controlled-multiple-sorter.demo.md +++ b/src/data-table/demos/enUS/controlled-multiple-sorter.demo.vue @@ -1,22 +1,30 @@ + # Controlled multi-column sorting If column object's `sortOrder` is set to `'ascend'`, `'descend'` or `false`, the data table would be in controlled state. If you only want UI to display multiple sort state, you can leave `compare` empty. + -```html - -``` - -```js + + + diff --git a/src/data-table/demos/enUS/index.demo-entry.md b/src/data-table/demos/enUS/index.demo-entry.md index 4fba767196b..18791b9546b 100644 --- a/src/data-table/demos/enUS/index.demo-entry.md +++ b/src/data-table/demos/enUS/index.demo-entry.md @@ -38,7 +38,7 @@ group-header.vue controlled-page.vue controlled-filter.vue controlled-sorter.vue -controlled-multiple-sorter +controlled-multiple-sorter.vue fixed-header.vue fixed-header-column.vue summary.vue diff --git a/src/data-table/demos/zhCN/controlled-multiple-sorter.demo.md b/src/data-table/demos/zhCN/controlled-multiple-sorter.demo.vue similarity index 64% rename from src/data-table/demos/zhCN/controlled-multiple-sorter.demo.md rename to src/data-table/demos/zhCN/controlled-multiple-sorter.demo.vue index 95c1ca70932..d89b6455759 100644 --- a/src/data-table/demos/zhCN/controlled-multiple-sorter.demo.md +++ b/src/data-table/demos/zhCN/controlled-multiple-sorter.demo.vue @@ -1,22 +1,30 @@ + # 受控的多列排序 如果列对象的 `sortOrder` 属性被设为 `'ascend'`、`'descend'` 或者 `false`,表格的排序将为受控状态。 如果你只需要 UI 显示多列排序的状态,那么不传 `compare` 即可。 + -```html - -``` - -```js + + + diff --git a/src/data-table/demos/zhCN/index.demo-entry.md b/src/data-table/demos/zhCN/index.demo-entry.md index f25af678ec4..8cb385c3da1 100644 --- a/src/data-table/demos/zhCN/index.demo-entry.md +++ b/src/data-table/demos/zhCN/index.demo-entry.md @@ -40,7 +40,7 @@ group-header.vue controlled-page.vue controlled-filter.vue controlled-sorter.vue -controlled-multiple-sorter +controlled-multiple-sorter.vue fixed-header.vue fixed-header-column.vue summary.vue From 9d80ee3bca9c61d24c5dcffa4766aeb4e260345f Mon Sep 17 00:00:00 2001 From: Artea Date: Mon, 13 Jan 2025 02:50:03 +0800 Subject: [PATCH 05/15] fix(data-table): expose method `sort` prama type --- src/data-table/src/interface.ts | 2 +- src/data-table/src/use-sorter.ts | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/data-table/src/interface.ts b/src/data-table/src/interface.ts index b965367cd76..c1dda47c348 100644 --- a/src/data-table/src/interface.ts +++ b/src/data-table/src/interface.ts @@ -545,7 +545,7 @@ export interface DataTableInst { clearFilters: () => void clearSorter: () => void page: (page: number) => void - sort: (columnKey: ColumnKey, order: SortOrder) => void + sort: (columnKey: ColumnKey | null, order?: SortOrder) => void scrollTo: ScrollTo downloadCsv: (options?: CsvOptionsType) => void /** @deprecated it but just leave it here, it does no harm */ diff --git a/src/data-table/src/use-sorter.ts b/src/data-table/src/use-sorter.ts index e86410fab25..56a5b086743 100644 --- a/src/data-table/src/use-sorter.ts +++ b/src/data-table/src/use-sorter.ts @@ -220,7 +220,10 @@ export function useSorter( uncontrolledSortStateRef.value = sortState } - function sort(columnKey: ColumnKey, order: SortOrder = 'ascend'): void { + function sort( + columnKey: ColumnKey | null, + order: SortOrder = 'ascend' + ): void { if (!columnKey) { clearSorter() } From 1f2f462d36693cc0f871699f915a1faf738b98cd Mon Sep 17 00:00:00 2001 From: Artea Date: Mon, 13 Jan 2025 02:50:45 +0800 Subject: [PATCH 06/15] docs(data-table): mutiple-sorter ts demo Signed-off-by: Artea --- src/data-table/demos/enUS/index.demo-entry.md | 2 +- ...orter.demo.md => multiple-sorter.demo.vue} | 75 ++++++++++++------- src/data-table/demos/zhCN/index.demo-entry.md | 2 +- ...orter.demo.md => multiple-sorter.demo.vue} | 75 ++++++++++++------- 4 files changed, 98 insertions(+), 56 deletions(-) rename src/data-table/demos/enUS/{multiple-sorter.demo.md => multiple-sorter.demo.vue} (63%) rename src/data-table/demos/zhCN/{multiple-sorter.demo.md => multiple-sorter.demo.vue} (63%) diff --git a/src/data-table/demos/enUS/index.demo-entry.md b/src/data-table/demos/enUS/index.demo-entry.md index 18791b9546b..aeef3b4ff06 100644 --- a/src/data-table/demos/enUS/index.demo-entry.md +++ b/src/data-table/demos/enUS/index.demo-entry.md @@ -29,7 +29,7 @@ row-props.vue merge-cell.vue filter-and-sorter pagination-behavior-on-filter.vue -multiple-sorter +multiple-sorter.vue column-draggable.vue select.vue select-single.vue diff --git a/src/data-table/demos/enUS/multiple-sorter.demo.md b/src/data-table/demos/enUS/multiple-sorter.demo.vue similarity index 63% rename from src/data-table/demos/enUS/multiple-sorter.demo.md rename to src/data-table/demos/enUS/multiple-sorter.demo.vue index cac60221015..472f733b47a 100644 --- a/src/data-table/demos/enUS/multiple-sorter.demo.md +++ b/src/data-table/demos/enUS/multiple-sorter.demo.vue @@ -1,28 +1,24 @@ + # Multiple column sorting Set `multiple` and `compare` on `sorter` to enable multiple column sorting. `multiple` is the priority of sorting (larger value means higher priority). + -```html - - - Sort By Name (Ascend) - Filter Address (London) - Clear Filters - Clear Sorter - - - -``` - -```js + + + diff --git a/src/data-table/demos/zhCN/index.demo-entry.md b/src/data-table/demos/zhCN/index.demo-entry.md index 8cb385c3da1..27837f36148 100644 --- a/src/data-table/demos/zhCN/index.demo-entry.md +++ b/src/data-table/demos/zhCN/index.demo-entry.md @@ -31,7 +31,7 @@ row-props.vue merge-cell.vue filter-and-sorter pagination-behavior-on-filter.vue -multiple-sorter +multiple-sorter.vue column-draggable.vue select.vue select-single.vue diff --git a/src/data-table/demos/zhCN/multiple-sorter.demo.md b/src/data-table/demos/zhCN/multiple-sorter.demo.vue similarity index 63% rename from src/data-table/demos/zhCN/multiple-sorter.demo.md rename to src/data-table/demos/zhCN/multiple-sorter.demo.vue index eb5e143f1cf..f60f9123a1c 100644 --- a/src/data-table/demos/zhCN/multiple-sorter.demo.md +++ b/src/data-table/demos/zhCN/multiple-sorter.demo.vue @@ -1,28 +1,24 @@ + # 多列排序 为 `sorter` 设定 `multiple` 和 `compare` 来开启多列排序,其中 `multiple` 为多列排序的优先级,越高优先级越高。 + -```html - - - Sort By Name (Ascend) - Filter Address (London) - Clear Filters - Clear Sorter - - - -``` - -```js + + + From 148e46ddbfc5ab066e73454d74af2e469aecd53f Mon Sep 17 00:00:00 2001 From: Artea Date: Mon, 13 Jan 2025 03:04:06 +0800 Subject: [PATCH 07/15] docs(data-table): filter and sorter ts demo Signed-off-by: Artea --- ...ter.demo.md => filter-and-sorter.demo.vue} | 72 +++++++----- src/data-table/demos/enUS/index.demo-entry.md | 2 +- ...ter.demo.md => filter-and-sorter.demo.vue} | 70 +++++++----- .../demos/zhCN/filter-and-sortor.demo.md | 108 ------------------ src/data-table/demos/zhCN/index.demo-entry.md | 2 +- 5 files changed, 91 insertions(+), 163 deletions(-) rename src/data-table/demos/enUS/{filter-and-sorter.demo.md => filter-and-sorter.demo.vue} (54%) rename src/data-table/demos/zhCN/{filter-and-sorter.demo.md => filter-and-sorter.demo.vue} (55%) delete mode 100644 src/data-table/demos/zhCN/filter-and-sortor.demo.md diff --git a/src/data-table/demos/enUS/filter-and-sorter.demo.md b/src/data-table/demos/enUS/filter-and-sorter.demo.vue similarity index 54% rename from src/data-table/demos/enUS/filter-and-sorter.demo.md rename to src/data-table/demos/enUS/filter-and-sorter.demo.vue index 8c6e20e7612..dccd98ff50d 100644 --- a/src/data-table/demos/enUS/filter-and-sorter.demo.md +++ b/src/data-table/demos/enUS/filter-and-sorter.demo.vue @@ -1,26 +1,19 @@ -# Uncontrolled filter and sorter + + # Uncontrolled filter and sorter + -```html - - - Sort By Name (Ascend) - Filter Address (London) - Clear Filters - Clear Sorter - - - -``` - -```js + + + diff --git a/src/data-table/demos/enUS/index.demo-entry.md b/src/data-table/demos/enUS/index.demo-entry.md index aeef3b4ff06..9668fcfa8fc 100644 --- a/src/data-table/demos/enUS/index.demo-entry.md +++ b/src/data-table/demos/enUS/index.demo-entry.md @@ -27,7 +27,7 @@ border.vue size.vue row-props.vue merge-cell.vue -filter-and-sorter +filter-and-sorter.vue pagination-behavior-on-filter.vue multiple-sorter.vue column-draggable.vue diff --git a/src/data-table/demos/zhCN/filter-and-sorter.demo.md b/src/data-table/demos/zhCN/filter-and-sorter.demo.vue similarity index 55% rename from src/data-table/demos/zhCN/filter-and-sorter.demo.md rename to src/data-table/demos/zhCN/filter-and-sorter.demo.vue index 3448f39838e..5034dbbd303 100644 --- a/src/data-table/demos/zhCN/filter-and-sorter.demo.md +++ b/src/data-table/demos/zhCN/filter-and-sorter.demo.vue @@ -1,26 +1,19 @@ + # 非受控过滤 & 排序 + -```html - - - Sort By Name (Ascend) - Filter Address (London) - Clear Filters - Clear Sorter - - - -``` - -```js + + + diff --git a/src/data-table/demos/zhCN/filter-and-sortor.demo.md b/src/data-table/demos/zhCN/filter-and-sortor.demo.md deleted file mode 100644 index 3448f39838e..00000000000 --- a/src/data-table/demos/zhCN/filter-and-sortor.demo.md +++ /dev/null @@ -1,108 +0,0 @@ -# 非受控过滤 & 排序 - -```html - - - Sort By Name (Ascend) - Filter Address (London) - Clear Filters - Clear Sorter - - - -``` - -```js -import { defineComponent, ref } from 'vue' - -const columns = [ - { - title: 'Name', - key: 'name', - defaultSortOrder: 'ascend', - sorter: 'default' - }, - { - title: 'Age', - key: 'age', - sorter: (row1, row2) => row1.age - row2.age - }, - { - title: 'Address', - key: 'address', - defaultFilterOptionValues: ['London', 'New York'], - filterOptions: [ - { - label: 'London', - value: 'London' - }, - { - label: 'New York', - value: 'New York' - } - ], - filter(value, row) { - return ~row.address.indexOf(value) - } - } -] - -const data = [ - { - key: 0, - name: 'John Brown', - age: 32, - address: 'New York No. 1 Lake Park' - }, - { - key: 1, - name: 'Jim Green', - age: 42, - address: 'London No. 1 Lake Park' - }, - { - key: 2, - name: 'Joe Black', - age: 32, - address: 'Sidney No. 1 Lake Park' - }, - { - key: 3, - name: 'Jim Red', - age: 32, - address: 'London No. 2 Lake Park' - } -] - -export default defineComponent({ - setup() { - const tableRef = ref(null) - - return { - table: tableRef, - data, - columns, - pagination: { pageSize: 5 }, - filterAddress() { - tableRef.value.filter({ - address: ['London'] - }) - }, - sortName() { - tableRef.value.sort('name', 'ascend') - }, - clearFilters() { - tableRef.value.filter(null) - }, - clearSorter() { - tableRef.value.sort(null) - } - } - } -}) -``` diff --git a/src/data-table/demos/zhCN/index.demo-entry.md b/src/data-table/demos/zhCN/index.demo-entry.md index 27837f36148..5ae377dc47f 100644 --- a/src/data-table/demos/zhCN/index.demo-entry.md +++ b/src/data-table/demos/zhCN/index.demo-entry.md @@ -29,7 +29,7 @@ border.vue size.vue row-props.vue merge-cell.vue -filter-and-sorter +filter-and-sorter.vue pagination-behavior-on-filter.vue multiple-sorter.vue column-draggable.vue From 13659f9609a053ce972501247ebb92e0e7dc898f Mon Sep 17 00:00:00 2001 From: Artea Date: Mon, 13 Jan 2025 04:22:00 +0800 Subject: [PATCH 08/15] docs(data-table): async ts demo&export DataTableFilterOptionValue Signed-off-by: Artea --- ...ajax-usage.demo.md => ajax-usage.demo.vue} | 145 +++++++++++------- src/data-table/demos/enUS/index.demo-entry.md | 2 +- ...ajax-usage.demo.md => ajax-usage.demo.vue} | 143 ++++++++++------- src/data-table/demos/zhCN/index.demo-entry.md | 2 +- src/data-table/index.ts | 1 + 5 files changed, 184 insertions(+), 109 deletions(-) rename src/data-table/demos/enUS/{ajax-usage.demo.md => ajax-usage.demo.vue} (54%) rename src/data-table/demos/zhCN/{ajax-usage.demo.md => ajax-usage.demo.vue} (55%) diff --git a/src/data-table/demos/enUS/ajax-usage.demo.md b/src/data-table/demos/enUS/ajax-usage.demo.vue similarity index 54% rename from src/data-table/demos/enUS/ajax-usage.demo.md rename to src/data-table/demos/enUS/ajax-usage.demo.vue index 81de148ddb0..acf6f8347ab 100644 --- a/src/data-table/demos/enUS/ajax-usage.demo.md +++ b/src/data-table/demos/enUS/ajax-usage.demo.vue @@ -1,31 +1,33 @@ -# Async + + # Async + -```html - -``` - -```js + + + diff --git a/src/data-table/demos/enUS/index.demo-entry.md b/src/data-table/demos/enUS/index.demo-entry.md index 9668fcfa8fc..076b3d3021f 100644 --- a/src/data-table/demos/enUS/index.demo-entry.md +++ b/src/data-table/demos/enUS/index.demo-entry.md @@ -47,7 +47,7 @@ ellipsis-tooltip.vue expand.vue render-header.vue custom-style.vue -ajax-usage +ajax-usage.vue virtual.vue virtual-x.vue custom-filter-menu.vue diff --git a/src/data-table/demos/zhCN/ajax-usage.demo.md b/src/data-table/demos/zhCN/ajax-usage.demo.vue similarity index 55% rename from src/data-table/demos/zhCN/ajax-usage.demo.md rename to src/data-table/demos/zhCN/ajax-usage.demo.vue index 18f7f8a8f2b..640028a6e41 100644 --- a/src/data-table/demos/zhCN/ajax-usage.demo.md +++ b/src/data-table/demos/zhCN/ajax-usage.demo.vue @@ -1,31 +1,33 @@ + # 异步 + -```html - -``` - -```js + + + diff --git a/src/data-table/demos/zhCN/index.demo-entry.md b/src/data-table/demos/zhCN/index.demo-entry.md index 5ae377dc47f..37405b50d9d 100644 --- a/src/data-table/demos/zhCN/index.demo-entry.md +++ b/src/data-table/demos/zhCN/index.demo-entry.md @@ -49,7 +49,7 @@ ellipsis-tooltip.vue expand.vue render-header.vue custom-style.vue -ajax-usage +ajax-usage.vue virtual.vue virtual-x.vue custom-filter-menu.vue diff --git a/src/data-table/index.ts b/src/data-table/index.ts index 6e44afd22db..a32c5f98e7a 100644 --- a/src/data-table/index.ts +++ b/src/data-table/index.ts @@ -11,6 +11,7 @@ export type { CreateRowProps as DataTableCreateRowProps, CreateSummary as DataTableCreateSummary, TableExpandColumn as DataTableExpandColumn, + FilterOptionValue as DataTableFilterOptionValue, FilterState as DataTableFilterState, DataTableInst, DataTableProps, From 125b6badfd5245f76675847fbe267e1f5e40d0f7 Mon Sep 17 00:00:00 2001 From: Artea Date: Mon, 13 Jan 2025 13:55:11 +0800 Subject: [PATCH 09/15] fix: typo of filter-and-sorter demo Signed-off-by: Artea --- src/data-table/demos/enUS/filter-and-sorter.demo.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/data-table/demos/enUS/filter-and-sorter.demo.vue b/src/data-table/demos/enUS/filter-and-sorter.demo.vue index dccd98ff50d..c229d588fa3 100644 --- a/src/data-table/demos/enUS/filter-and-sorter.demo.vue +++ b/src/data-table/demos/enUS/filter-and-sorter.demo.vue @@ -1,6 +1,6 @@ - + # Uncontrolled filter and sorter - +