Skip to content

Commit 49a45d5

Browse files
fixed different column height
1 parent 6adf481 commit 49a45d5

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

source/css/LightPivot.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@
9595
text-align: right;
9696
text-overflow: ellipsis;
9797
overflow: hidden;
98+
padding: 0 6px !important;
9899
}
99100

100101
.lpt .lpt-topSection, .lpt .lpt-bottomSection {

source/js/PivotView.js

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ PivotView.prototype.removeDataWait = function () {
266266
};
267267

268268
/**
269-
* @param {HTMLElement} container
269+
* @param container
270270
*/
271271
PivotView.prototype.recalculateSizes = function (container) {
272272

@@ -281,6 +281,7 @@ PivotView.prototype.recalculateSizes = function (container) {
281281
leftHeader = container.getElementsByClassName("lpt-leftHeader")[0],
282282
lTableHead = leftHeader.getElementsByTagName("thead")[0],
283283
tableBlock = container.getElementsByClassName("lpt-tableBlock")[0],
284+
pTableHead = tableBlock.getElementsByTagName("tbody")[0],
284285
tableTr = tableBlock.getElementsByTagName("tr")[0];
285286

286287
if (tTableHead.childNodes[0] && tTableHead.childNodes[0].lastChild["_extraCell"]) {
@@ -297,7 +298,7 @@ PivotView.prototype.recalculateSizes = function (container) {
297298
hasVerticalScrollBar = tableBlock.scrollHeight > containerHeight - headerH,
298299
addExtraTopHeaderCell = tTableHead.offsetWidth > topHeader.offsetWidth,
299300
addExtraLeftHeaderCell = lTableHead.offsetHeight > containerHeight - headerH,
300-
cell, tr, cellWidths = [], i;
301+
cell, tr, cellWidths = [], columnHeights = [], i;
301302

302303
headerContainer.style.width = headerW + "px";
303304
if (container["_primaryColumns"]) {
@@ -307,6 +308,13 @@ PivotView.prototype.recalculateSizes = function (container) {
307308
} else {
308309
console.warn("No _primaryColumns property in container, cell sizes won't be fixed.");
309310
}
311+
if (container["_primaryRows"]) {
312+
for (i in container["_primaryRows"]) {
313+
columnHeights.push(container["_primaryRows"][i].offsetHeight);
314+
}
315+
} else {
316+
console.warn("No _primaryRows property in container, cell sizes won't be fixed.");
317+
}
310318

311319
container.parentNode.removeChild(container); // detach
312320

@@ -344,6 +352,13 @@ PivotView.prototype.recalculateSizes = function (container) {
344352
if (tableTr.childNodes[i].tagName !== "TD") continue;
345353
tableTr.childNodes[i].style.width = cellWidths[i] + "px";
346354
}
355+
for (i in pTableHead.childNodes) {
356+
if (pTableHead.childNodes[i].tagName !== "TR") continue;
357+
if (pTableHead.childNodes[i].firstChild) {
358+
pTableHead.childNodes[i].firstChild.style.height =
359+
(columnHeights[i] || 0) + "px";
360+
}
361+
}
347362

348363
containerParent.appendChild(container); // attach
349364

@@ -389,7 +404,7 @@ PivotView.prototype.renderRawData = function (data) {
389404
LHTHead = document.createElement("thead"),
390405
mainTable = document.createElement("table"),
391406
mainTBody = document.createElement("tbody"),
392-
x, y, tr = null, th, td, primaryColumns = [];
407+
x, y, tr = null, th, td, primaryColumns = [], primaryRows = [];
393408

394409
// clean previous content
395410
this.removeMessage();
@@ -434,6 +449,7 @@ PivotView.prototype.renderRawData = function (data) {
434449

435450
// add listeners
436451
if (vertical && x === xTo - 1) {
452+
primaryRows.push(th);
437453
th.addEventListener(CLICK_EVENT, (function (index, data) {
438454
return function () {
439455
_._rowClickHandler.call(_, index, data);
@@ -538,6 +554,7 @@ PivotView.prototype.renderRawData = function (data) {
538554
container.appendChild(pivotTopSection);
539555
container.appendChild(pivotBottomSection);
540556
container["_primaryColumns"] = primaryColumns;
557+
container["_primaryRows"] = primaryRows;
541558

542559
this.recalculateSizes(container);
543560

0 commit comments

Comments
 (0)