From d6daf466ace42b828151c45b18cd47179e85d66d Mon Sep 17 00:00:00 2001 From: kyyy <60952577+rdjanuar@users.noreply.github.com> Date: Fri, 8 Nov 2024 23:24:41 +0700 Subject: [PATCH] feat(Table): allow dynamically render `checkbox` (#2549) Co-authored-by: Benjamin Canac --- .../content/examples/TableExampleAdvanced.vue | 6 +- ...ableExampleDynamicallyRenderSelectable.vue | 64 +++++++++++ docs/content/2.components/table.md | 100 +++++++++++++++++- src/runtime/components/data/Table.vue | 90 ++++++++++------ 4 files changed, 224 insertions(+), 36 deletions(-) create mode 100644 docs/components/content/examples/TableExampleDynamicallyRenderSelectable.vue diff --git a/docs/components/content/examples/TableExampleAdvanced.vue b/docs/components/content/examples/TableExampleAdvanced.vue index e76b7835..981ebaaa 100644 --- a/docs/components/content/examples/TableExampleAdvanced.vue +++ b/docs/components/content/examples/TableExampleAdvanced.vue @@ -1,6 +1,9 @@ + + diff --git a/docs/content/2.components/table.md b/docs/content/2.components/table.md index 8fbe24fe..f107ea3e 100644 --- a/docs/content/2.components/table.md +++ b/docs/content/2.components/table.md @@ -285,6 +285,29 @@ componentProps: --- :: +#### Single Select Mode +Control how the select function allows only one row to be selected at a time. + +```vue + +``` + +#### Checkbox Placement +You can customize the checkbox column position by using the `select` key in the `columns` configuration. + +::component-example{class="grid"} +--- +extraClass: 'overflow-hidden' +padding: false +component: 'table-example-dynamically-render-selectable' +componentProps: + class: 'flex-1' +--- +:: + ### Contextmenu Use the `contextmenu` listener on your Table to make the rows righ-clickable. The function will receive the original event as the first argument and the row as the second argument. @@ -393,7 +416,6 @@ Controls whether multiple rows can be expanded simultaneously in the table. - ``` #### Disable Row Expansion @@ -534,6 +556,82 @@ componentProps: --- :: +### `select-header` +This slot allows you to customize the checkbox appearance in the table header for selecting all rows at once while using feature [Selectable](#selectable). + +#### Usage +```vue + +``` + +#### Props + +| Prop | Type | Description | +|------|------|-------------| +| `checked` | `Boolean` | Indicates if all rows are selected | +| `change` | `Function` | Function to handle selection state changes. Must receive a boolean value (true/false) | +| `indeterminate` | `Boolean` | Indicates partial selection (when some rows are selected) | + +#### Example +```vue + +``` + +### `select-data` +This slot allows you to customize the checkbox appearance for each row in the table while using feature [Selectable](#selectable). + +#### Usage +```vue + +``` + +#### Props + +| Prop | Type | Description | +|------|------|-------------| +| `checked` | `Boolean` | Indicates if the current row is selected | +| `change` | `Function` | Function to handle selection state changes. Must receive a boolean value (true/false) | + +#### Example +```vue + +``` + ### `expand-action` The `#expand-action` slot allows you to customize the expansion control interface for expandable table rows. This feature provides a flexible way to implement custom expand/collapse functionality while maintaining access to essential row data and state. diff --git a/src/runtime/components/data/Table.vue b/src/runtime/components/data/Table.vue index 6c68eb8e..cf5dc076 100644 --- a/src/runtime/components/data/Table.vue +++ b/src/runtime/components/data/Table.vue @@ -8,28 +8,27 @@ - - - - Expand - - + + + + +