diff --git a/components/tree/Tree.tsx b/components/tree/Tree.tsx index 92e8fe41ad..367e89c666 100644 --- a/components/tree/Tree.tsx +++ b/components/tree/Tree.tsx @@ -86,6 +86,16 @@ export interface AntTreeNodeDropEvent { event: React.MouseEvent; } +export interface TreeNodeNormal { + title?: React.ReactNode; + key: string; + isLeaf?: boolean; + disabled?: boolean; + disableCheckbox?: boolean; + selectable?: boolean; + children?: TreeNodeNormal[]; +} + export interface TreeProps { showLine?: boolean; className?: string; @@ -153,6 +163,7 @@ export interface TreeProps { filterTreeNode?: (node: AntTreeNode) => boolean; children?: React.ReactNode; blockNode?: boolean; + treeData?: Array; } export default class Tree extends React.Component { diff --git a/components/tree/index.en-US.md b/components/tree/index.en-US.md index e5a97fbc01..ca81f133f6 100644 --- a/components/tree/index.en-US.md +++ b/components/tree/index.en-US.md @@ -46,6 +46,7 @@ Almost anything can be represented in a tree structure. Examples include directo | onLoad | Callback function for when a treeNode is loaded | function(loadedKeys, {event, node}) | - | | onRightClick | Callback function for when the user right clicks a treeNode | function({event, node}) | - | | onSelect | Callback function for when the user clicks a treeNode | function(selectedKeys, e:{selected: bool, selectedNodes, node, event}) | - | +| treeData | treeNodes data Array, if set it then you need not to construct children TreeNode. (key should be unique across the whole array) | array\<{ key, title, children, \[disabled, selectable] }> | - | ### TreeNode props diff --git a/components/tree/index.zh-CN.md b/components/tree/index.zh-CN.md index 974760dddf..2b6fbe94dd 100644 --- a/components/tree/index.zh-CN.md +++ b/components/tree/index.zh-CN.md @@ -47,6 +47,7 @@ subtitle: 树形控件 | onLoad | 节点加载完毕时触发 | function(loadedKeys, {event, node}) | - | | onRightClick | 响应右键点击 | function({event, node}) | - | | onSelect | 点击树节点触发 | function(selectedKeys, e:{selected: bool, selectedNodes, node, event}) | - | +| treeData | treeNodes 数据,如果设置则不需要手动构造 TreeNode 节点(key 在整个树范围内唯一) | array\<{key, title, children, \[disabled, selectable]}> | - | ### TreeNode props