@beisen-phoenix/rc-tree
v1.0.17-rc.2
Published
---
Downloads
36
Readme
rc-tree
API
Tree props
| name | description | type | default |
|----------|----------------|----------|--------------|
| autoExpandParent | 自动展开指定的父节点 | bool | false |
| checkable | 节点前添加 Checkbox 复选框 | bool/React Node | false |
| checkedKeys | 受控选中的树节点(设置后,默认选中的键将不起作用)。注意:父节点和子节点是关联的,如果父节点的键存在,则检查所有子节点,反之亦然。当设置checkable和checkstricle时,它应该是一个包含checked数组和半checked数组的对象。 | String[]/{checked:Array,halfChecked:Array} | [] |
| checkStrictly| checkable状态下节点选择完全受控(父子节点选中状态不再关联) | bool | false |
| className | 根dom节点的附加css类 | String | '' |
| defaultCheckedKeys | 默认选中复选框的树节点 | String[] | [] |
| defaultExpandedKeys | 默认展开指定的树节点 | String[] | - |
| defaultExpandAll | 默认展开所有树节点 | bool | false |
| defaultExpandParent | 默认展开父节点 | bool | true |
| defaultSelectedKeys | 默认选中的树节点 | String[] | [] |
| disabled | 是否禁用树 | bool | false |
| draggable | 设置节点可拖拽(IE>8) | bool | false |
| expandedKeys |(受控)展开指定的树节点 | String[] | - |
| filterTreeNode | 按需筛选树节点(高亮),返回true | function(node) | - |
| icon | 自定义图标。可接收组件,props 为当前节点 props | element/Function(props) | - |
| loadedKeys | 受控)已经加载的节点,需要配合 loadData
使用 | string[] | - |
| loadData | 异步加载数据,返回值应该是一个promise | function(node) | - |
| multiple | 支持点选多个节点(节点本身) | bool | false |
| prefixCls | 样式前缀 | String | 'rc-loadDatatree' |
| selectable | 是否可以被选中 | bool | true |
| selectedKeys | 受控选定树节点(设置后,默认选定的键将不起作用) | String[] | [] |
| showIcon | 是否显示图标 | bool | true |
| singleLine | 设置是否整行选中 | bool | false |
| treeData | TreeNodes数据数组,如果设置了它,则不需要构造子TreeNode。(值在整个数组中应该是唯一的),***h目前仅对treeData方式的使用,做了整行选择样式支持扩展,其他使用保持原组件方式***
| array<{key,title,children, [disabled, selectable]}> | - |
| onCheck | 单击TreeNode/复选框触发 | function(checkedKeys, e:{checked: bool, checkedNodes, node, event, nativeEvent}) | - |
| onExpand | 展开/收起节点时触发 | function(expandedKeys, {expanded: bool, node, nativeEvent}) | - |
| onDragEnd | dragend 触发时调用| function({event,node}) | - |
| onDragEnter | dragenter 触发时调用 | function({event,node,expandedKeys}) | - |
| onDragLeave | dragleave 触发时调用 | function({event,node}) | - |
| onDragOver | dragover 触发时调用(一直) | function({event,node}) | - |
| onDragStart | dragstart 触发时调用 | function({event,node}) | - |
| onDrop | drop 触发时调用 | function({event, node, dragNode, dragNodesKeys}) | - |
| onLoad | 节点加载完毕时触发 | - |
| onMouseEnter | 当鼠标进入TreeNode时调用 | function({event,node}) | - |
| onMouseLeave | 当鼠标离开TreeNode时调用 | function({event,node}) | - |
| onRightClick | 响应右键点击 | function({event,node}) | - |
| onSelect | 节点选中时触发 | function(selectedKeys, e:{selected: bool, selectedNodes, node, event, nativeEvent}) | - |
| switcherIcon | 指定节点切换图标 | ReactNode / (props: TreeNodeAttribute) => ReactNode | - |
TreeNode props
note: if you have a lot of TreeNode, like more than 1000,
make the parent node is collapsed by default, will obvious effect, very fast.
Because the children hide TreeNode will not insert into dom.
| name | description | type | default | |----------|----------------|----------|--------------| |className | 节点附加的样式 | String | '' | |style | 设置节点的style样式 | Object | '' | |disabled | 是否禁用Treenode | bool | false | |disableCheckbox | 是否禁用Treenode'复选框 | bool | false | |title | 树/子树的标题 | String/element | '---' | |key | 节点标识,全局唯一。它与树属性(默认)expandedkeys/(默认)checkedkeys/(默认)selectedkeys一起使用。 | String | treeNode's position | |isLeaf | 是否为叶节点 | bool | false | |icon | 自定义图标。可接收组件,props 为当前节点 props | element/Function(props) | - | | switcherIcon | 指定节点切换图标 | ReactNode / (props: TreeNodeAttribute) => ReactNode | - |
note
The number of treeNodes can be very large, but when enable checkable
,
it will spend more computing time, so we cached some calculations(e.g. this.treeNodesStates
),
to avoid double computing. But, this bring some restrictions,
when you async load treeNodes, you should render tree like this
{this.state.treeData.length ? <Tree ...>{this.state.treeData.map(t => <TreeNode ... />)}</Tree> : 'loading tree'}
Development
npm install
npm start
Test Case
http://localhost:8018/tests/runner.html?coverage
Coverage
http://localhost:8018/node_modules/rc-server/node_modules/node-jscover/lib/front-end/jscoverage.html?w=http://localhost:8018/tests/runner.html?coverage
License
rc-tree is released under the MIT license.