From 9ddbd5c0d2885acb7fa1c069fdf9f3b13af0981b Mon Sep 17 00:00:00 2001 From: Ilya Torovin <94941930+Lol1chw@users.noreply.github.com> Date: Mon, 8 Jul 2024 18:38:54 +0700 Subject: [PATCH] docs: expanding table in `data-table` component --- .../src/content/docs/components/data-table.md | 236 +++++++++++++++++- .../example/DataTableColumnPinningDemo.vue | 41 +-- .../default/example/DataTableDemo.vue | 28 ++- .../default/example/DataTableDemoColumn.vue | 7 + .../example/DataTableColumnPinningDemo.vue | 41 +-- .../new-york/example/DataTableDemo.vue | 28 ++- .../new-york/example/DataTableDemoColumn.vue | 7 + 7 files changed, 333 insertions(+), 55 deletions(-) diff --git a/apps/www/src/content/docs/components/data-table.md b/apps/www/src/content/docs/components/data-table.md index d36f2104..b43074b4 100644 --- a/apps/www/src/content/docs/components/data-table.md +++ b/apps/www/src/content/docs/components/data-table.md @@ -866,11 +866,237 @@ This adds a checkbox to each row and a checkbox in the header to select all rows You can show the number of selected rows using the `table.getFilteredSelectedRowModel()` API. -```vue -
- {{ table.getFilteredSelectedRowModel().rows.length }} of - {{ table.getFilteredRowModel().rows.length }} row(s) selected. -
+```vue:line-numbers {8-11} + + +``` + + + + + +## Expanding + +Let's make rows expandable. + +### Update `` + +```vue:line-numbers {7,30,43,52,57,63,103-116} + + + +``` + +### Add the expand action to the `DataTableDropDown.vue` component + +```vue:line-numbers {12-14,34-36} + + + +``` + +### Make rows expandable + +Now we can update the action cell to add the expand control. + +```vue:line-numbers {11} + + ``` diff --git a/apps/www/src/lib/registry/default/example/DataTableColumnPinningDemo.vue b/apps/www/src/lib/registry/default/example/DataTableColumnPinningDemo.vue index 16d27c9d..e6cb4617 100644 --- a/apps/www/src/lib/registry/default/example/DataTableColumnPinningDemo.vue +++ b/apps/www/src/lib/registry/default/example/DataTableColumnPinningDemo.vue @@ -1,6 +1,7 @@ @@ -201,15 +208,18 @@ const table = useVueTable({ diff --git a/apps/www/src/lib/registry/default/example/DataTableDemoColumn.vue b/apps/www/src/lib/registry/default/example/DataTableDemoColumn.vue index 1292cba3..93f7ba71 100644 --- a/apps/www/src/lib/registry/default/example/DataTableDemoColumn.vue +++ b/apps/www/src/lib/registry/default/example/DataTableDemoColumn.vue @@ -9,6 +9,10 @@ defineProps<{ } }>() +defineEmits<{ + (e: 'expand'): void +}>() + function copy(id: string) { navigator.clipboard.writeText(id) } @@ -27,6 +31,9 @@ function copy(id: string) { Copy payment ID + + Expand + View customer View payment details diff --git a/apps/www/src/lib/registry/new-york/example/DataTableColumnPinningDemo.vue b/apps/www/src/lib/registry/new-york/example/DataTableColumnPinningDemo.vue index 1f6f129d..7c3e0242 100644 --- a/apps/www/src/lib/registry/new-york/example/DataTableColumnPinningDemo.vue +++ b/apps/www/src/lib/registry/new-york/example/DataTableColumnPinningDemo.vue @@ -1,6 +1,7 @@ @@ -201,15 +208,18 @@ const table = useVueTable({ diff --git a/apps/www/src/lib/registry/new-york/example/DataTableDemoColumn.vue b/apps/www/src/lib/registry/new-york/example/DataTableDemoColumn.vue index 7031caa8..22c51491 100644 --- a/apps/www/src/lib/registry/new-york/example/DataTableDemoColumn.vue +++ b/apps/www/src/lib/registry/new-york/example/DataTableDemoColumn.vue @@ -9,6 +9,10 @@ defineProps<{ } }>() +defineEmits<{ + (e: 'expand'): void +}>() + function copy(id: string) { navigator.clipboard.writeText(id) } @@ -27,6 +31,9 @@ function copy(id: string) { Copy payment ID + + Expand + View customer View payment details