Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Table): resizable属性开启后,翻页之后各列宽度未能保存(#2386) #2433

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/table/BaseTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const BaseTable = forwardRef<BaseTableRef, BaseTableProps>((props, ref) => {
resizable,
lazyLoad,
pagination,
isStatic = false,
} = props;
const tableRef = useRef<HTMLDivElement>();
const tableElmRef = useRef<HTMLTableElement>();
Expand All @@ -56,7 +57,7 @@ const BaseTable = forwardRef<BaseTableRef, BaseTableProps>((props, ref) => {
const { isMultipleHeader, spansAndLeafNodes, thList } = useTableHeader({ columns: props.columns });
const finalColumns = useMemo(
() => spansAndLeafNodes?.leafColumns || columns,
[spansAndLeafNodes?.leafColumns, columns],
isStatic ? [] : [spansAndLeafNodes?.leafColumns, columns],
);

// 固定表头和固定列逻辑
Expand Down
2 changes: 2 additions & 0 deletions src/table/table.en-US.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
:: BASE_DOC ::

## API

### BaseTable Props

name | type | default | description | required
Expand All @@ -11,6 +12,7 @@ attach | String / Function | - | elements with popup would be attached to `attac
bordered | Boolean | false | show table bordered | N
bottomContent | TNode | - | Typescript:`string \| TNode`。[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
cellEmptyContent | TNode | - | Typescript:`string \| TNode<BaseTableCellParams<T>>`。[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
isStatic | Boolean | false | Static table,used in scenarios where the columns attribute of the table does not change dynamically。Typescript:`boolean`。| N
columns | Array | [] | table column configs。Typescript:`Array<BaseTableCol<T>>` | N
data | Array | [] | table data。Typescript:`Array<T>` | N
disableDataPage | Boolean | false | \- | N
Expand Down
2 changes: 2 additions & 0 deletions src/table/table.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
:: BASE_DOC ::

## API

### BaseTable Props

名称 | 类型 | 默认值 | 说明 | 必传
Expand All @@ -11,6 +12,7 @@ attach | String / Function | - | 超出省略等所有浮层元素统一绑定
bordered | Boolean | false | 是否显示表格边框 | N
bottomContent | TNode | - | 表格底部内容,可以用于自定义列设置等。TS 类型:`string \| TNode`。[通用类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
cellEmptyContent | TNode | - | 单元格数据为空时呈现的内容。TS 类型:`string \| TNode<BaseTableCellParams<T>>`。[通用类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
isStatic | Boolean | false | 静态的表格,用于表格的columns属性不会动态变化的场景。TS 类型:`boolean`。| N
columns | Array | [] | 列配置,泛型 T 指表格数据类型。TS 类型:`Array<BaseTableCol<T>>` | N
data | Array | [] | 数据源,泛型 T 指表格数据类型。TS 类型:`Array<T>` | N
disableDataPage | Boolean | false | 是否禁用本地数据分页。当 `data` 数据长度超过分页大小时,会自动进行本地数据分页。如果 `disableDataPage` 设置为 true,则无论何时,都不会进行本地数据分页 | N
Expand Down
4 changes: 4 additions & 0 deletions src/table/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ export interface TdBaseTableProps<T extends TableRowData = TableRowData> {
* 单元格数据为空时呈现的内容
*/
cellEmptyContent?: string | TNode<BaseTableCellParams<T>>;
/**
* 静态的表格,用于表格的columns属性不会动态变化的场景 @link https://github.com/Tencent/tdesign-react/issues/2386
*/
isStatic?: Boolean;
/**
* 列配置,泛型 T 指表格数据类型
* @default []
Expand Down