Skip to content

Commit a05df7e

Browse files
committed
docs: demo and changelog
1 parent 016aaa2 commit a05df7e

File tree

4 files changed

+56
-4
lines changed

4 files changed

+56
-4
lines changed

Diff for: CHANGELOG.md

-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ All notable changes to this project will be documented in this file. See [standa
3737
### Bug Fixes
3838

3939
- fix immediate option in userList ([#378](https://github.com/DTStack/dt-react-component/issues/378)) ([b8992f3](https://github.com/DTStack/dt-react-component/commit/b8992f38f918dde10cb6349e39aca2c524e70853))
40-
> > > > > > > 272326794683ecd3ed1846ad38fd4258b23dc0f7
4140

4241
## [4.2.0](https://github.com/DTStack/dt-react-component/compare/v4.1.0...v4.2.0) (2023-08-24)
4342

Diff for: docs/guide/migration-v4.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,10 @@ useCookieListener(
150150

151151
- 新增 `observerEle` 属性,支持自定义监听元素。
152152

153-
#### SpreadSheet [#325](https://github.com/DTStack/dt-react-component/pull/325)
153+
#### SpreadSheet [#325](https://github.com/DTStack/dt-react-component/pull/325)[#545](https://github.com/DTStack/dt-react-component/pull/545)
154154

155155
- 新增 `className` 属性,可自定义外层组件的 class 名。
156+
- 删除 `showCopyWithHeader` 属性,使用 `copyTypes` 属性代替,值为数组,可传入 'copyData'、'copyHeaders'、'copyHeadersAndData',分别代表的功能为:复制值、复制列名、复制列名和值。
156157

157158
#### KeyEventListener [#326](https://github.com/DTStack/dt-react-component/pull/326)
158159

Diff for: src/spreadSheet/demos/changeData.tsx

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import React, { useRef, useState } from 'react';
2+
import { Button } from 'antd';
3+
import { SpreadSheet } from 'dt-react-component';
4+
5+
export default () => {
6+
const _columns = ['name', 'gender', 'age', 'address'];
7+
const _data = [
8+
['zhangsan', 'male', '20', 'xihu'],
9+
['lisi', 'male', '18', 'yuhang'],
10+
[' 前面有空格', '后面有空格 ', '中间有 空 格', 'yuhang'],
11+
];
12+
const [columns, setColumns] = useState(_columns);
13+
const [data, setData] = useState(_data);
14+
const hotTableInstanceRef = useRef<any>(null);
15+
16+
const handleData = () => {
17+
setData(data?.length === 2 ? _data : _data.slice(0, 2));
18+
};
19+
20+
const handleColumns = () => {
21+
setColumns(columns?.length === 3 ? _columns : _columns.slice(0, 3));
22+
};
23+
24+
const handleRef = () => {
25+
console.log(hotTableInstanceRef?.current?.hotInstance?.getData());
26+
};
27+
28+
return (
29+
<>
30+
<Button style={{ margin: '0 12px 12px 0' }} type="primary" onClick={handleColumns}>
31+
改变列
32+
</Button>
33+
<Button style={{ margin: '0 12px 12px 0' }} type="primary" onClick={handleData}>
34+
改变数据
35+
</Button>
36+
<Button style={{ margin: '0 12px 12px 0' }} type="primary" onClick={handleRef}>
37+
使用 HotTable 示例(打印数据)
38+
</Button>
39+
40+
<SpreadSheet
41+
ref={hotTableInstanceRef}
42+
columns={columns}
43+
data={data}
44+
options={{
45+
trimWhitespace: false,
46+
copyTypes: ['copyData', 'copyHeaders', 'copyHeadersAndData'],
47+
}}
48+
/>
49+
</>
50+
);
51+
};

Diff for: src/spreadSheet/index.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: SpreadSheet 多功能表
33
group: 组件
44
toc: content
55
demo:
6-
cols: 2
6+
cols: 1
77
---
88

99
# SpreadSheet 多功能表
@@ -14,7 +14,8 @@ demo:
1414

1515
## 示例
1616

17-
<code src="./demos/basic.tsx">基础使用</code>
17+
<code src="./demos/basic.tsx" title="基础使用"></code>
18+
<code src="./demos/changeData.tsx" title="改变数据"></code>
1819

1920
## API
2021

0 commit comments

Comments
 (0)