Support changing column count

rel-1.0
Vitaliy Filippov 2016-08-12 21:25:10 +03:00
parent ea22e29fea
commit 6f9d8ebc9e
1 changed files with 32 additions and 4 deletions

View File

@ -69,6 +69,7 @@ function makeStickyHeaders(table)
e.style.left = l[i]+'px';
e.style.display = 'block';
e.style.zIndex = '1';
e._sticky = true;
}
// Try to minimise reflows: (1) make some changes
for (var i = rs.length-1; i >= 0; i--)
@ -215,7 +216,7 @@ function fixStickyColumnSizes(table, force)
b = table.rows[0].children[0];
b.style.width = w[1]+'px';
b.style.height = h[1]+'px';
for (var i = 2; i < table._sizerow.children.length; i++)
for (var i = 1; i < table._sizerow.children.length; i++)
{
b = table.rows[0].children[i];
b.style.left = l[i]+'px';
@ -247,11 +248,13 @@ function fixStickyHeader(table, nocols)
var sr = table._sizerow;
while (sr.children[1])
sr.removeChild(sr.children[1]);
var e, renew = false;
for (var i = 0; i < tr.children.length; i++)
{
if (i == 1)
continue;
var e = tr.children[i].cloneNode(true);
e = tr.children[i];
if (!e._sticky)
renew = true;
e = e.cloneNode(true);
if (i == 0)
e.className = e.className.replace(' _scri'+table._scri, '');
e.style.position = '';
@ -261,6 +264,31 @@ function fixStickyHeader(table, nocols)
e.style.display = '';
e.style.zIndex = '';
sr.appendChild(e);
if (e._sticky && i == 0)
i++;
}
if (renew)
{
for (var i = 0; i < tr.children.length; i++)
{
var e = tr.children[i];
if (!e._sticky)
{
e.style.position = 'absolute';
e.style.display = 'block';
e.style.zIndex = '1';
if (i == 0)
{
var d = e.cloneNode(true);
d.style.visibility = 'hidden';
tr.insertBefore(d, e.nextSibling);
i++;
e.className += ' _scri'+table._scri;
e.style.zIndex = '2';
}
}
}
table._widths = [];
}
if (!nocols)
fixStickyColumnSizes(table);