From e3bb6819848535e9b32c57de154bfafec023520f Mon Sep 17 00:00:00 2001 From: qiang Date: Fri, 13 Sep 2024 14:13:33 +0800 Subject: [PATCH] fix(components): [table] the disabled checkbox are selected (#18034) * fix(components): [table] non selectable items are selected closed #18021 * docs: update --- docs/en-US/component/table.md | 34 ++++++++++--------- docs/examples/table/multi-select.vue | 30 +++++++++++----- .../components/table/__tests__/table.test.ts | 13 +++++++ .../components/table/src/store/watcher.ts | 11 ++++-- .../table/src/table/utils-helper.ts | 8 +++-- 5 files changed, 68 insertions(+), 28 deletions(-) diff --git a/docs/en-US/component/table.md b/docs/en-US/component/table.md index e584ef092b..f8d8726818 100644 --- a/docs/en-US/component/table.md +++ b/docs/en-US/component/table.md @@ -129,6 +129,8 @@ table/single-select You can also select multiple rows. +After ^(2.8.3), `toggleRowSelection` supports the third parameter `ignoreSelectable` to determine whether to ignore the selectable attribute. + :::demo Activating multiple selection is easy: simply add an `el-table-column` with its `type` set to `selection`. table/multi-select @@ -320,22 +322,22 @@ table/table-layout ### Table Exposes -| Method | Description | Type | -| ------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------- | -| clearSelection | used in multiple selection Table, clear user selection | ^[Function]`() => void` | -| getSelectionRows | returns the currently selected rows | ^[Function]`() => any[]` | -| toggleRowSelection | used in multiple selection Table, toggle if a certain row is selected. With the second parameter, you can directly set if this row is selected | ^[Function]`(row: any, selected?: boolean) => void` | -| toggleAllSelection | used in multiple selection Table, toggle select all and deselect all | ^[Function]`() => void` | -| toggleRowExpansion | used in expandable Table or tree Table, toggle if a certain row is expanded. With the second parameter, you can directly set if this row is expanded or collapsed | ^[Function]`(row: any, expanded?: boolean) => void` | -| setCurrentRow | used in single selection Table, set a certain row selected. If called without any parameter, it will clear selection | ^[Function]`(row: any) => void` | -| clearSort | clear sorting, restore data to the original order | ^[Function]`() => void` | -| clearFilter | clear filters of the columns whose `columnKey` are passed in. If no params, clear all filters | ^[Function]`(columnKeys?: string[]) => void` | -| doLayout | refresh the layout of Table. When the visibility of Table changes, you may need to call this method to get a correct layout | ^[Function]`() => void` | -| sort | sort Table manually. Property `prop` is used to set sort column, property `order` is used to set sort order | ^[Function]`(prop: string, order: string) => void` | -| scrollTo | scrolls to a particular set of coordinates | ^[Function]`(options: number \| ScrollToOptions, yCoord?: number) => void` | -| setScrollTop | set vertical scroll position | ^[Function]`(top?: number) => void` | -| setScrollLeft | set horizontal scroll position | ^[Function]`(left?: number) => void` | -| columns ^(2.7.6) | Get table columns context. | ^[array]`TableColumnCtx[]` | +| Method | Description | Type | +| ------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------- | +| clearSelection | used in multiple selection Table, clear user selection | ^[Function]`() => void` | +| getSelectionRows | returns the currently selected rows | ^[Function]`() => any[]` | +| toggleRowSelection | used in multiple selection Table, toggle if a certain row is selected. With the second parameter, you can directly set if this row is selected | ^[Function]`(row: any, selected?: boolean, ignoreSelectable = true) => void` | +| toggleAllSelection | used in multiple selection Table, toggle select all and deselect all | ^[Function]`() => void` | +| toggleRowExpansion | used in expandable Table or tree Table, toggle if a certain row is expanded. With the second parameter, you can directly set if this row is expanded or collapsed | ^[Function]`(row: any, expanded?: boolean) => void` | +| setCurrentRow | used in single selection Table, set a certain row selected. If called without any parameter, it will clear selection | ^[Function]`(row: any) => void` | +| clearSort | clear sorting, restore data to the original order | ^[Function]`() => void` | +| clearFilter | clear filters of the columns whose `columnKey` are passed in. If no params, clear all filters | ^[Function]`(columnKeys?: string[]) => void` | +| doLayout | refresh the layout of Table. When the visibility of Table changes, you may need to call this method to get a correct layout | ^[Function]`() => void` | +| sort | sort Table manually. Property `prop` is used to set sort column, property `order` is used to set sort order | ^[Function]`(prop: string, order: string) => void` | +| scrollTo | scrolls to a particular set of coordinates | ^[Function]`(options: number \| ScrollToOptions, yCoord?: number) => void` | +| setScrollTop | set vertical scroll position | ^[Function]`(top?: number) => void` | +| setScrollLeft | set horizontal scroll position | ^[Function]`(left?: number) => void` | +| columns ^(2.7.6) | Get table columns context. | ^[array]`TableColumnCtx[]` | ## Table-column API diff --git a/docs/examples/table/multi-select.vue b/docs/examples/table/multi-select.vue index 19d5c401ca..d1b5138276 100644 --- a/docs/examples/table/multi-select.vue +++ b/docs/examples/table/multi-select.vue @@ -5,7 +5,7 @@ style="width: 100%" @selection-change="handleSelectionChange" > - + @@ -16,29 +16,36 @@ Toggle selection status of second and third rows + + Toggle selection status based on selectable + Clear selection