diff --git a/docs/en-US/component/table.md b/docs/en-US/component/table.md index 984e790cab..d9d21124e5 100644 --- a/docs/en-US/component/table.md +++ b/docs/en-US/component/table.md @@ -321,7 +321,7 @@ table/table-layout | ------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------- | | clearSelection | used in multiple selection Table, clear user selection | ^[Function]`() => void` | | getSelectionRows | returns the currently selected rows | ^[Function]`() => void` | -| 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` | +| 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` | diff --git a/packages/components/table/src/store/watcher.ts b/packages/components/table/src/store/watcher.ts index cd35b5cb88..6552b23006 100644 --- a/packages/components/table/src/store/watcher.ts +++ b/packages/components/table/src/store/watcher.ts @@ -190,7 +190,7 @@ function useWatcher() { const toggleRowSelection = ( row: T, - selected = undefined, + selected?: boolean, emitChange = true ) => { const changed = toggleRowStatus(selection.value, row, selected) diff --git a/packages/components/table/src/table/utils-helper.ts b/packages/components/table/src/table/utils-helper.ts index 99768ab0c6..f09abfbf01 100644 --- a/packages/components/table/src/table/utils-helper.ts +++ b/packages/components/table/src/table/utils-helper.ts @@ -8,7 +8,7 @@ function useUtils(store: Store) { const getSelectionRows = () => { return store.getSelectionRows() } - const toggleRowSelection = (row: T, selected: boolean) => { + const toggleRowSelection = (row: T, selected?: boolean) => { store.toggleRowSelection(row, selected, false) store.updateAllSelected() } diff --git a/packages/components/table/src/util.ts b/packages/components/table/src/util.ts index 5c4f9f14cd..8bf4ddba6f 100644 --- a/packages/components/table/src/util.ts +++ b/packages/components/table/src/util.ts @@ -263,7 +263,7 @@ export function compose(...funcs) { export function toggleRowStatus( statusArr: T[], row: T, - newVal: boolean + newVal?: boolean ): boolean { let changed = false const index = statusArr.indexOf(row)