Skip to content

Commit dbf3e73

Browse files
complex column sizes fix
1 parent d2c999b commit dbf3e73

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

source/js/PivotView.js

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ PivotView.prototype.init = function () {
7676

7777
this.pushTable();
7878

79-
this.displayMessage("Loading...");
79+
this.displayMessage(navigator.language === "ru" ? "Загрузка..." : "Loading...");
8080

8181
window.addEventListener("resize", function () {
8282
_.updateSizes.call(_);
@@ -257,6 +257,14 @@ PivotView.prototype.removeMessage = function () {
257257

258258
};
259259

260+
PivotView.prototype.displayDataWait = function () {
261+
262+
};
263+
264+
PivotView.prototype.removeDataWait = function () {
265+
266+
};
267+
260268
/**
261269
* @param {HTMLElement} container
262270
*/
@@ -270,8 +278,6 @@ PivotView.prototype.recalculateSizes = function (container) {
270278
headerContainer = container.getElementsByClassName("lpt-header")[0],
271279
topHeader = container.getElementsByClassName("lpt-topHeader")[0],
272280
tTableHead = topHeader.getElementsByTagName("thead")[0],
273-
topTableTr = topHeader.getElementsByTagName("tr")
274-
[topHeader.getElementsByTagName("tr").length - 1],
275281
leftHeader = container.getElementsByClassName("lpt-leftHeader")[0],
276282
lTableHead = leftHeader.getElementsByTagName("thead")[0],
277283
tableBlock = container.getElementsByClassName("lpt-tableBlock")[0],
@@ -294,9 +300,12 @@ PivotView.prototype.recalculateSizes = function (container) {
294300
cell, tr, cellWidths = [], i;
295301

296302
headerContainer.style.width = headerW + "px";
297-
for (i in topTableTr.childNodes) {
298-
if (!tableTr.childNodes[i] || tableTr.childNodes[i].tagName !== "TD") continue;
299-
cellWidths.push(topTableTr.childNodes[i].offsetWidth);
303+
if (container["_primaryColumns"]) {
304+
for (i in container["_primaryColumns"]) {
305+
cellWidths.push(container["_primaryColumns"][i].offsetWidth);
306+
}
307+
} else {
308+
console.warn("No _primaryColumns property in container, cell sizes won't be fixed.");
300309
}
301310

302311
container.parentNode.removeChild(container); // detach
@@ -380,7 +389,7 @@ PivotView.prototype.renderRawData = function (data) {
380389
LHTHead = document.createElement("thead"),
381390
mainTable = document.createElement("table"),
382391
mainTBody = document.createElement("tbody"),
383-
x, y, tr = null, th, td;
392+
x, y, tr = null, th, td, primaryColumns = [];
384393

385394
// clean previous content
386395
this.removeMessage();
@@ -432,6 +441,7 @@ PivotView.prototype.renderRawData = function (data) {
432441
}
433442
if (!vertical && y === yTo - 1 && !th["_hasSortingListener"]) {
434443
th["_hasSortingListener"] = false;
444+
primaryColumns.push(th);
435445
th.addEventListener(CLICK_EVENT, (function (i) {
436446
return function () {
437447
_._columnClickHandler.call(_, i);
@@ -526,6 +536,7 @@ PivotView.prototype.renderRawData = function (data) {
526536
pivotBottomSection.appendChild(tableBlock);
527537
container.appendChild(pivotTopSection);
528538
container.appendChild(pivotBottomSection);
539+
container["_primaryColumns"] = primaryColumns;
529540

530541
this.recalculateSizes(container);
531542

0 commit comments

Comments
 (0)