From d435a6a6fcda591e48ac2a7cf6d3de0aff3c5808 Mon Sep 17 00:00:00 2001 From: msidolphin Date: Sun, 13 Mar 2022 23:00:58 +0800 Subject: [PATCH] feat(components): [el-table] exposes scroll methods (#6539) * feat(components): [el-table] exposes scroll methods * chore: improve code --- docs/en-US/component/table.md | 27 ++++++++++-------- .../table/fixed-header-with-fluid-header.vue | 3 +- .../table/src/composables/use-scrollbar.ts | 28 +++++++++++++++++++ packages/components/table/src/table.vue | 10 ++++++- .../table/src/table/style-helper.ts | 10 +++---- 5 files changed, 59 insertions(+), 19 deletions(-) create mode 100644 packages/components/table/src/composables/use-scrollbar.ts diff --git a/docs/en-US/component/table.md b/docs/en-US/component/table.md index 35e79d65ae..cf3d2fd3b7 100644 --- a/docs/en-US/component/table.md +++ b/docs/en-US/component/table.md @@ -278,18 +278,21 @@ table/table-layout ## Table Methods -| Method | Description | Parameters | -| ------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------- | -| clearSelection | used in multiple selection Table, clear user selection | — | -| getSelectionRows | returns the currently selected rows | | -| 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 | row, selected | -| toggleAllSelection | used in multiple selection Table, toggle select all and deselect all | — | -| 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 | row, expanded | -| setCurrentRow | used in single selection Table, set a certain row selected. If called without any parameter, it will clear selection. | row | -| clearSort | clear sorting, restore data to the original order | — | -| clearFilter | clear filters of the columns whose `columnKey` are passed in. If no params, clear all filters | columnKeys | -| doLayout | refresh the layout of Table. When the visibility of Table changes, you may need to call this method to get a correct layout | — | -| sort | sort Table manually. Property `prop` is used to set sort column, property `order` is used to set sort order | prop: string, order: string | +| Method | Description | Parameters | +| ------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------- | +| clearSelection | used in multiple selection Table, clear user selection | — | +| getSelectionRows | returns the currently selected rows | | +| 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 | row, selected | +| toggleAllSelection | used in multiple selection Table, toggle select all and deselect all | — | +| 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 | row, expanded | +| setCurrentRow | used in single selection Table, set a certain row selected. If called without any parameter, it will clear selection. | row | +| clearSort | clear sorting, restore data to the original order | — | +| clearFilter | clear filters of the columns whose `columnKey` are passed in. If no params, clear all filters | columnKeys | +| doLayout | refresh the layout of Table. When the visibility of Table changes, you may need to call this method to get a correct layout | — | +| sort | sort Table manually. Property `prop` is used to set sort column, property `order` is used to set sort order | prop: string, order: string | +| scrollTo | scrolls to a particular set of coordinates | `{ top?: number, left?: number }` | +| setScrollTop | set vertical scroll position | top | +| setScrollLeft | set horizontal scroll position | left | ## Table Slots diff --git a/docs/examples/table/fixed-header-with-fluid-header.vue b/docs/examples/table/fixed-header-with-fluid-header.vue index 71ff8d2e46..d689ca2825 100644 --- a/docs/examples/table/fixed-header-with-fluid-header.vue +++ b/docs/examples/table/fixed-header-with-fluid-header.vue @@ -25,6 +25,7 @@