Make FHT refresh header on each setup call

rel-1.0
Vitaliy Filippov 2016-03-04 12:27:56 +03:00
parent 28f2a68d9a
commit a718b47be7
2 changed files with 18 additions and 11 deletions

View File

@ -47,7 +47,7 @@ TreeGrid.prototype.setHeader = function(newHeader)
this.header = newHeader;
// header change clears the whole grid by now
if (this.root)
this.root.setChildren([]);
this.root.setChildren(false, []);
}
TreeGrid.prototype.onExpand = function(node)
@ -159,16 +159,18 @@ 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);
this.leaf = isLeaf;
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)
this.tr.cells[0].firstChild.className = 'collapser collapser-inactive';
else
this.tr.cells[0].firstChild.className = this.collapsed ? 'collapser collapser-collapsed' : 'collapser collapser-expanded';
}
this.children = [];
var insertBefore = this.tr && this.tr.nextSibling;
for (var i = 0; i < newChildren.length; i++)

View File

@ -19,10 +19,17 @@ onDomReady(function()
var i = {
cells: [ 'Payment from Gazprom to Shell 2', '4', '5' ]
};
var TG = new TreeGrid([ {
cells: [ 'Payment from Gazprom to Shell', '2', '3' ]
} ], [ '', '15 фев', '16 фев', '17 фев', '18 фев', '19 фев', '20 фев', '21 фев' ]);
var TG = new TreeGrid([], []);
TG.table.className = 'grid';
document.getElementById('innerdiv').appendChild(TG.table);
$(TG.table).fixedHeaderTable({});
setTimeout(function() {
TG.setHeader([ '', '15 фев', '16 фев', '17 фев', '18 фев', '19 фев', '20 фев', '21 фев' ]);
TG.root.setChildren(false, [ {
cells: [ 'Payment from Gazprom to Shell', '2', '3' ]
} ]);
$(TG.table).fixedHeaderTable({});
}, 1000);
TG.onExpand = function(node)
{
// Dynamic loading example
@ -38,8 +45,6 @@ onDomReady(function()
}, 100);
return false;
};
document.getElementById('innerdiv').appendChild(TG.table);
$(TG.table).fixedHeaderTable({});
// Cell editing example
$(TG.table).dblclick(function(evt)