add addChildren() method
parent
48934f8370
commit
f4ea9e29b1
|
@ -1,7 +1,7 @@
|
||||||
/**
|
/**
|
||||||
* Very simple and fast tree grid/table, compatible with dynamic loading and jQuery fixedHeaderTable
|
* Very simple and fast tree grid/table, compatible with dynamic loading and jQuery fixedHeaderTable
|
||||||
* License: MPL 2.0+, (c) Vitaliy Filippov 2016+
|
* License: MPL 2.0+, (c) Vitaliy Filippov 2016+
|
||||||
* Version: 2016-03-10
|
* Version: 2016-03-25
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -401,7 +401,14 @@ TreeGridNode.prototype.setChildren = function(isLeaf, newChildren)
|
||||||
this.tr.cells[0].firstChild.className = this.collapsed ? 'collapser collapser-collapsed' : 'collapser collapser-expanded';
|
this.tr.cells[0].firstChild.className = this.collapsed ? 'collapser collapser-collapsed' : 'collapser collapser-expanded';
|
||||||
}
|
}
|
||||||
this.children = [];
|
this.children = [];
|
||||||
|
this.addChildren(newChildren);
|
||||||
|
}
|
||||||
|
|
||||||
|
TreeGridNode.prototype.addChildren = function(newChildren)
|
||||||
|
{
|
||||||
var insertBefore = this.tr && this.tr.nextSibling;
|
var insertBefore = this.tr && this.tr.nextSibling;
|
||||||
|
while (insertBefore && insertBefore.nextSibling && insertBefore._node.level > this.level)
|
||||||
|
insertBefore = insertBefore.nextSibling;
|
||||||
for (var i = 0; i < newChildren.length; i++)
|
for (var i = 0; i < newChildren.length; i++)
|
||||||
this.children.push(new TreeGridNode(newChildren[i], this.grid, this.level+1, insertBefore, this.collapsed));
|
this.children.push(new TreeGridNode(newChildren[i], this.grid, this.level+1, insertBefore, this.collapsed));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue