Save existing groups when adding a grouping
parent
1bc8a8a13d
commit
2ba72731fc
32
treegrid.js
32
treegrid.js
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
* Very simple and fast tree grid/table, compatible with dynamic loading and jQuery fixedHeaderTable
|
||||
* License: MPL 2.0+, (c) Vitaliy Filippov 2016+
|
||||
* Version: 2016-04-13
|
||||
* Version: 2016-05-15
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -347,8 +347,7 @@ function TreeGridNode(node, grid, level, insertBefore, startHidden)
|
|||
else
|
||||
{
|
||||
collapser.className = this.collapsed ? 'collapser collapser-collapsed' : 'collapser collapser-expanded';
|
||||
var self = this;
|
||||
addListener(collapser, 'click', function(e) { self._toggleHandler(); });
|
||||
addListener(collapser, 'click', this._getToggleHandler());
|
||||
}
|
||||
var c0 = this.tr.cells[0];
|
||||
c0.childNodes.length ? c0.insertBefore(collapser, c0.firstChild) : c0.appendChild(collapser);
|
||||
|
@ -370,6 +369,14 @@ function TreeGridNode(node, grid, level, insertBefore, startHidden)
|
|||
this.children.push(new TreeGridNode(node.children[i], grid, this.level+1, insertBefore, this.collapsed));
|
||||
}
|
||||
|
||||
TreeGridNode.prototype._getToggleHandler = function()
|
||||
{
|
||||
var self = this;
|
||||
if (!self._toggleHandlerClosure)
|
||||
self._toggleHandlerClosure = function(e) { self._toggleHandler(); };
|
||||
return self._toggleHandlerClosure;
|
||||
}
|
||||
|
||||
TreeGridNode.prototype._toggleHandler = function()
|
||||
{
|
||||
if (!this.grid.onExpand(this))
|
||||
|
@ -409,18 +416,27 @@ TreeGridNode.prototype.toggle = function()
|
|||
|
||||
TreeGridNode.prototype.setChildren = function(isLeaf, newChildren)
|
||||
{
|
||||
this.leaf = isLeaf;
|
||||
if (!this.tr)
|
||||
this.grid.tbody.innerHTML = '';
|
||||
else
|
||||
{
|
||||
while (this.tr.nextSibling && this.tr.nextSibling._node.level > this.level)
|
||||
this.grid.tbody.removeChild(this.tr.nextSibling);
|
||||
if (this.leaf)
|
||||
this.tr.cells[0].firstChild.className = 'collapser collapser-inactive';
|
||||
else
|
||||
this.tr.cells[0].firstChild.className = this.collapsed ? 'collapser collapser-collapsed' : 'collapser collapser-expanded';
|
||||
if (this.leaf != isLeaf)
|
||||
{
|
||||
if (isLeaf)
|
||||
{
|
||||
this.tr.cells[0].firstChild.className = 'collapser collapser-inactive';
|
||||
removeListener(this.tr.cells[0].firstChild, 'click', this._getToggleHandler());
|
||||
}
|
||||
else
|
||||
{
|
||||
this.tr.cells[0].firstChild.className = this.collapsed ? 'collapser collapser-collapsed' : 'collapser collapser-expanded';
|
||||
addListener(this.tr.cells[0].firstChild, 'click', this._getToggleHandler());
|
||||
}
|
||||
}
|
||||
}
|
||||
this.leaf = isLeaf;
|
||||
this.children = [];
|
||||
this.addChildren(newChildren);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue