-
Notifications
You must be signed in to change notification settings - Fork 202
Expand file tree
/
Copy pathcontrolled.js
More file actions
72 lines (65 loc) · 2.17 KB
/
Copy pathcontrolled.js
File metadata and controls
72 lines (65 loc) · 2.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/* eslint react/no-multi-comp:0, no-console:0, no-alert: 0 */
import 'rc-tree-select/assets/index.less';
import React from 'react';
import 'rc-dialog/assets/index.css';
import TreeSelect, { TreeNode } from 'rc-tree-select';
import './demo.less';
class Demo extends React.Component {
state = {
treeExpandedKeys: [],
};
onTreeExpand = treeExpandedKeys => {
this.setState({
treeExpandedKeys,
});
};
treeExpandedKeys = () => {
this.setState({
treeExpandedKeys: ['000', '0-1-0'],
});
};
render() {
const { treeExpandedKeys } = this.state;
return (
<div>
<h2>Conrolled treeExpandedKeys</h2>
<TreeSelect
style={{ width: 200 }}
dropdownStyle={{ maxHeight: 200, overflow: 'auto' }}
treeExpandedKeys={treeExpandedKeys}
onTreeExpand={this.onTreeExpand}
>
<TreeNode value="" title="parent 1" key="000">
<TreeNode value="parent 1-0" title="parent 1-0" key="0-1-0">
<TreeNode value="leaf1" title="my leaf" key="random" />
<TreeNode value="leaf2" title="your leaf" key="random1" disabled />
</TreeNode>
<TreeNode value="parent 1-1" title="parent 1-1" key="0-1-1">
<TreeNode
value="sss"
title={<span style={{ color: 'red' }}>sss</span>}
key="random3"
/>
<TreeNode value="same value1" title="same txtle" key="0-1-1-1">
<TreeNode
value="same value10"
title="same titlexd"
key="0-1-1-1-0"
style={{ color: 'red', background: 'green' }}
/>
</TreeNode>
</TreeNode>
</TreeNode>
<TreeNode value="same value2" title="same title" key="0-2">
<TreeNode value="2same value" title="2same title" key="0-2-0" />
</TreeNode>
<TreeNode value="same value3" title="same title" key="0-3" />
</TreeSelect>
<button type="button" onClick={this.treeExpandedKeys}>
Set treeExpandedKeys
</button>
</div>
);
}
}
export default () => <Demo />;