mirror of
https://github.com/ElemeFE/element.git
synced 2025-12-19 12:04:02 +08:00
Tree: fix setCheckedKeys() not work on node that has childNodes (#2967)
This commit is contained in:
@@ -118,7 +118,7 @@
|
||||
} else {
|
||||
hasChild = Math.random() > 0.5;
|
||||
}
|
||||
|
||||
|
||||
setTimeout(function() {
|
||||
let data;
|
||||
if (hasChild) {
|
||||
@@ -130,7 +130,7 @@
|
||||
} else {
|
||||
data = [];
|
||||
}
|
||||
|
||||
|
||||
resolve(data);
|
||||
}, 500);
|
||||
},
|
||||
@@ -161,11 +161,11 @@
|
||||
append(store, data) {
|
||||
store.append({ id: id++, label: 'testtest', children: [] }, data);
|
||||
},
|
||||
|
||||
|
||||
remove(store, data) {
|
||||
store.remove(data);
|
||||
},
|
||||
|
||||
|
||||
renderContent(h, { node, data, store }) {
|
||||
return (
|
||||
<span>
|
||||
@@ -178,13 +178,13 @@
|
||||
</span>
|
||||
</span>);
|
||||
},
|
||||
|
||||
|
||||
filterNode(value, data) {
|
||||
if (!value) return true;
|
||||
return data.label.indexOf(value) !== -1;
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
data() {
|
||||
return {
|
||||
data,
|
||||
@@ -200,7 +200,7 @@
|
||||
};
|
||||
</script>
|
||||
|
||||
## Tree
|
||||
## Tree
|
||||
|
||||
Display a set of data with hierarchies.
|
||||
|
||||
@@ -452,7 +452,7 @@ Tree nodes can be initially expanded or checked
|
||||
this.$refs.tree.setCheckedKeys([]);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
data() {
|
||||
return {
|
||||
data2: [{
|
||||
@@ -518,7 +518,7 @@ The content of tree nodes can be customized, so you can add icons or buttons as
|
||||
|
||||
<script>
|
||||
let id = 1000;
|
||||
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
@@ -563,16 +563,16 @@ The content of tree nodes can be customized, so you can add icons or buttons as
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
methods: {
|
||||
append(store, data) {
|
||||
store.append({ id: id++, label: 'testtest', children: [] }, data);
|
||||
},
|
||||
|
||||
|
||||
remove(store, data) {
|
||||
store.remove(data);
|
||||
},
|
||||
|
||||
|
||||
renderContent(h, { node, data, store }) {
|
||||
return (
|
||||
<span>
|
||||
@@ -777,8 +777,8 @@ Only one node among the same level can be expanded at one time.
|
||||
| filter | filter all tree nodes, filtered nodes will be hidden | Accept a parameter which will be used as first parameter for filter-node-method |
|
||||
| getCheckedNodes | If the node can be selected (`show-checkbox` is `true`), it returns the currently selected array of nodes | Accept a boolean type parameter whose default value is `false`. If the parameter is `true`, it only returns the currently selected array of sub-nodes. |
|
||||
| setCheckedNodes | set certain nodes to be checked, only works when `node-key` is assigned | an array of nodes to be checked |
|
||||
| getCheckedKeys | If the node can be selected (`show-checkbox` is `true`), it returns the currently selected array of node's keys | (leafOnly) Accept a boolean type parameter whose default value is `true`. If the parameter is `true`, it only returns the currently selected array of sub-nodes. |
|
||||
| setCheckedKeys | set certain nodes to be checked, only works when `node-key` is assigned | (keys, leafOnly) Accept two parameters: 1. an array of node's keys to be checked 2. a boolean type parameter whose default value is `true`. If the parameter is `true`, it only returns the currently selected array of sub-nodes. |
|
||||
| getCheckedKeys | If the node can be selected (`show-checkbox` is `true`), it returns the currently selected array of node's keys | (leafOnly) Accept a boolean type parameter whose default value is `false`. If the parameter is `true`, it only returns the currently selected array of sub-nodes. |
|
||||
| setCheckedKeys | set certain nodes to be checked, only works when `node-key` is assigned | (keys, leafOnly) Accept two parameters: 1. an array of node's keys to be checked 2. a boolean type parameter whose default value is `false`. If the parameter is `true`, it only returns the currently selected array of sub-nodes. |
|
||||
| setChecked | set node to be checked or not, only works when `node-key` is assigned | (key/data, checked, deep) Accept three parameters: 1. node's key or data to be checked 2. a boolean typed parameter indicating checked or not. 3. a boolean typed parameter indicating deep or not. |
|
||||
|
||||
### Events
|
||||
@@ -789,4 +789,3 @@ Only one node among the same level can be expanded at one time.
|
||||
| current-change | triggers when current node changes | two parameters: node object corresponding to the current node, `node` property of TreeNode |
|
||||
| node-expand | triggers when current node open | three parameters: node object corresponding to the node opened, `node` property of TreeNode, TreeNode itself |
|
||||
| node-collapse | triggers when current node close | three parameters: node object corresponding to the node closed, `node` property of TreeNode, TreeNode itself |
|
||||
|
||||
|
||||
Reference in New Issue
Block a user