Fix removeChild()

rel-1.0
Vitaliy Filippov 2016-10-24 14:22:07 +03:00
parent 6073f97c4a
commit 9cc2a9c60c
1 changed files with 5 additions and 2 deletions

View File

@ -1,7 +1,7 @@
/** /**
* Very simple and fast tree grid/table, compatible with dynamic loading and stickyheaders.js * Very simple and fast tree grid/table, compatible with dynamic loading and stickyheaders.js
* License: MPL 2.0+, (c) Vitaliy Filippov 2016+ * License: MPL 2.0+, (c) Vitaliy Filippov 2016+
* Version: 2016-10-08 * Version: 2016-10-24
*/ */
/** /**
@ -616,7 +616,10 @@ TreeGridNode.prototype.toggle = function()
TreeGridNode.prototype.setChildren = function(isLeaf, newChildren) TreeGridNode.prototype.setChildren = function(isLeaf, newChildren)
{ {
if (!this.tr) if (!this.tr)
{
// root node
this.grid.tbody.innerHTML = ''; this.grid.tbody.innerHTML = '';
}
else else
{ {
var tr = this.tr[this.tr.length-1]; var tr = this.tr[this.tr.length-1];
@ -653,7 +656,7 @@ TreeGridNode.prototype.removeChild = function(nodeOrIndex)
} }
if (!this.children[nodeOrIndex]) if (!this.children[nodeOrIndex])
return false; return false;
var e = this.children[nodeOrIndex].tr; var e = this.children[nodeOrIndex].tr[0];
var l = this.children[nodeOrIndex].level; var l = this.children[nodeOrIndex].level;
if (this.children[nodeOrIndex].key !== undefined) if (this.children[nodeOrIndex].key !== undefined)
delete this.childrenByKey[this.children[nodeOrIndex].key]; delete this.childrenByKey[this.children[nodeOrIndex].key];