up tree api

pull/162/head
然则 10 years ago
parent 452426d6f5
commit 011970fe38

@ -1,4 +1,4 @@
# 基本
# 复选框
- order: 1
@ -9,12 +9,15 @@
````jsx
var Tree = antd.Tree;
var TreeNode = Tree.TreeNode;
function handleCheck(checked, c, checkedKeys) {
console.log('checked: ', checked, c );
function handleCheck(info) {
console.log('check: ', info);
}
function handleSelect(info) {
console.log('select: ', info);
}
React.render(
<Tree defaultExpandAll={true} checkable={<span className="ant-tree-checkbox-inner"></span>} onCheck={handleCheck}>
<Tree defaultExpandAll={true} checkable={true} onCheck={handleCheck} onSelect={handleSelect}>
<TreeNode title="parent 1">
<TreeNode>leaf</TreeNode>
<TreeNode title="parent 1-1">

@ -4,11 +4,18 @@ import Tree from 'rc-tree';
const AntTree = React.createClass({
getDefaultProps() {
return {
prefixCls: 'ant-tree'
prefixCls: 'ant-tree',
checkable: false,
showIcon: false,
};
},
render() {
return <Tree {...this.props} showIcon={false}>
const props = this.props;
let checkable = props.checkable;
if (checkable) {
checkable = <span className={`${props.prefixCls}-checkbox-inner`}></span>;
}
return <Tree {...props} checkable={checkable}>
{this.props.children}
</Tree>;
}

@ -15,11 +15,14 @@
| 参数 | 说明 | 类型 | 默认值 |
|-----------|------------------------------------------|------------|--------|
|checkable | 是否支持选中 | bool/React Node | false |
|multiple | 是否支持多选 | bool | false |
|checkable | 是否支持选中 | bool | false |
|defaultExpandAll | 设置展开所有树节点 | bool | false |
|defaultExpandedKeys | 展开指定的树节点 | String[] | false |
|defaultCheckedKeys | 默认选中的树节点 | String[] | [] |
|onCheck | 点击树节点触发 | function(e:{checked:bool,node,checkedKeys}) | - |
|defaultCheckedKeys | 默认选中复选框的树节点 | String[] | [] |
|defaultSelectedKeys | 默认选中的树节点 | String[] | [] |
|onCheck | 点击树节点或复选框触发 | function(e:{checked:bool,node,checkedKeys,event}) | - |
|onSelect | 点击树节点触发 | function(e:{selected:bool,node,checkedKeys,event}) | - |
### TreeNode props

@ -42,6 +42,9 @@
color: #666;
}
span {
&.@{treePrefixCls}-checkbox {
margin: 3px 7px 0 0;
}
&.@{treePrefixCls}-switcher,
&.@{treePrefixCls}-iconEle {
line-height: 0;

Loading…
Cancel
Save