Save calendar state when modifying whole hier groups
parent
2ba72731fc
commit
51792b58d8
102
treegrid.js
102
treegrid.js
|
@ -441,11 +441,101 @@ TreeGridNode.prototype.setChildren = function(isLeaf, newChildren)
|
|||
this.addChildren(newChildren);
|
||||
}
|
||||
|
||||
TreeGridNode.prototype.addChildren = function(newChildren)
|
||||
TreeGridNode.prototype.syncChildren = function()
|
||||
{
|
||||
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++)
|
||||
this.children.push(new TreeGridNode(newChildren[i], this.grid, this.level+1, insertBefore, this.collapsed));
|
||||
var i, j;
|
||||
for (var i = 0; i < this.children.length; i++)
|
||||
{
|
||||
delete this.children[i]._rownum;
|
||||
}
|
||||
var rows = [];
|
||||
var e = this.tr ? this.tr.nextSibling : this.grid.tbody.firstChild;
|
||||
i = 0;
|
||||
while (e && e._node.level > this.level)
|
||||
{
|
||||
if (e._node.level == this.level+1)
|
||||
{
|
||||
if (rows.length > 0)
|
||||
rows[rows.length-1][2] = i;
|
||||
e._node._rownum = rows.length;
|
||||
rows.push([ e, i, i ]);
|
||||
}
|
||||
e = e.nextSibling;
|
||||
i++;
|
||||
}
|
||||
if (rows.length > 0)
|
||||
rows[rows.length-1][2] = i;
|
||||
e = this.tr ? this.tr.nextSibling : this.grid.tbody.firstChild;
|
||||
for (var i = 0; i < this.children.length; i++)
|
||||
{
|
||||
if (this.children[i]._rownum !== undefined)
|
||||
{
|
||||
var k = rows[this.children[i]._rownum][0];
|
||||
var n = rows[this.children[i]._rownum][2]-rows[this.children[i]._rownum][1];
|
||||
delete this.children[i]._rownum;
|
||||
var m;
|
||||
while (n > 0)
|
||||
{
|
||||
// Ставим k перед e
|
||||
m = k;
|
||||
k = k.nextSibling;
|
||||
if (!e)
|
||||
this.grid.tbody.appendChild(k);
|
||||
else if (e == k)
|
||||
e = e.nextSibling;
|
||||
else
|
||||
e.parentNode.insertBefore(k, e);
|
||||
n--;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.children[i] = new TreeGridNode(this.children[i], this.grid, this.level+1, e, this.collapsed);
|
||||
}
|
||||
}
|
||||
if (e)
|
||||
{
|
||||
while (e._node.level > this.level)
|
||||
{
|
||||
k = e;
|
||||
e = e.nextSibling;
|
||||
k.parentNode.removeChild(k);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TreeGridNode.prototype.removeChild = function(i)
|
||||
{
|
||||
if (!this.children[i])
|
||||
return null;
|
||||
var e = this.children[i].tr;
|
||||
var l = this.children[i].level;
|
||||
this.children.splice(i, 1);
|
||||
var k;
|
||||
do
|
||||
{
|
||||
k = e;
|
||||
e = e.nextSibling;
|
||||
k.parentNode.removeChild(k);
|
||||
} while (e && e._node.level > l);
|
||||
}
|
||||
|
||||
TreeGridNode.prototype.addChildren = function(nodes, insertBefore)
|
||||
{
|
||||
var e;
|
||||
if (insertBefore < 0)
|
||||
insertBefore = 0;
|
||||
if (insertBefore === undefined || insertBefore === null || insertBefore === false ||
|
||||
insertBefore >= this.children.length)
|
||||
{
|
||||
insertBefore = this.children.length;
|
||||
e = this;
|
||||
while (e.children.length)
|
||||
e = e.children[e.children.length-1];
|
||||
e = e.tr ? e.tr.nextSibling : null;
|
||||
}
|
||||
else
|
||||
e = this.children[insertBefore].tr;
|
||||
for (var i = 0; i < nodes.length; i++)
|
||||
this.children.splice(insertBefore+i, 0, new TreeGridNode(nodes[i], this.grid, this.level+1, e, this.collapsed));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue