mirror of https://github.com/ElemeFE/element
Tree: tree expend once when checked
parent
527f3bdbe9
commit
a408bf47fe
|
@ -42,6 +42,22 @@ const reInitChecked = function(node) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const initLazyLoadChild = node => {
|
||||||
|
const childNodes = node.childNodes;
|
||||||
|
if (node.checked) {
|
||||||
|
for (let i = 0, j = childNodes.length; i < j; i++) {
|
||||||
|
const child = childNodes[i];
|
||||||
|
if (!child.disabled) {
|
||||||
|
child.checked = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const parent = node.parent;
|
||||||
|
if (!parent || parent.level === 0) return;
|
||||||
|
reInitChecked(parent);
|
||||||
|
};
|
||||||
|
|
||||||
const getPropertyFromData = function(node, prop) {
|
const getPropertyFromData = function(node, prop) {
|
||||||
const props = node.store.props;
|
const props = node.store.props;
|
||||||
const data = node.data || {};
|
const data = node.data || {};
|
||||||
|
@ -245,6 +261,7 @@ export default class Node {
|
||||||
if (this.shouldLoadData()) {
|
if (this.shouldLoadData()) {
|
||||||
this.loadData((data) => {
|
this.loadData((data) => {
|
||||||
if (data instanceof Array) {
|
if (data instanceof Array) {
|
||||||
|
initLazyLoadChild(this);
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -290,8 +307,8 @@ export default class Node {
|
||||||
value = false;
|
value = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleDescendants = () => {
|
const handleDescendants = (lazy) => {
|
||||||
if (deep) {
|
if (deep && !lazy) {
|
||||||
const childNodes = this.childNodes;
|
const childNodes = this.childNodes;
|
||||||
for (let i = 0, j = childNodes.length; i < j; i++) {
|
for (let i = 0, j = childNodes.length; i < j; i++) {
|
||||||
const child = childNodes[i];
|
const child = childNodes[i];
|
||||||
|
@ -310,7 +327,7 @@ export default class Node {
|
||||||
if (!this.store.checkStrictly && this.shouldLoadData()) {
|
if (!this.store.checkStrictly && this.shouldLoadData()) {
|
||||||
// Only work on lazy load data.
|
// Only work on lazy load data.
|
||||||
this.loadData(() => {
|
this.loadData(() => {
|
||||||
handleDescendants();
|
handleDescendants(true);
|
||||||
}, {
|
}, {
|
||||||
checked: value !== false
|
checked: value !== false
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue