Skip to content

Commit 0e0082a

Browse files
Table headers height fix to be consistent with data cells height
1 parent 3602d62 commit 0e0082a

File tree

2 files changed

+30
-15
lines changed

2 files changed

+30
-15
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "LightPivotTable",
33
"author": "ZitRo",
4-
"version": "1.5.3",
4+
"version": "1.6.0",
55
"description": "A lightweight pivot table for MDX2JSON source for InterSystems Cache",
66
"main": "test/testServer.js",
77
"repository": {

source/js/PivotView.js

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -797,7 +797,7 @@ PivotView.prototype.recalculateSizes = function (container) {
797797
}
798798

799799
var addEggs = hasVerticalScrollBar && !IS_LISTING,
800-
cell, tr, cellWidths = [], columnHeights = [], i,
800+
cell, tr, cellWidths = [], rowHeadersHeights = [], rowDataHeights = [], i,
801801
headerCellApplied = false;
802802

803803
var applyExtraTopHeadCell = function () {
@@ -826,9 +826,12 @@ PivotView.prototype.recalculateSizes = function (container) {
826826
} else {
827827
console.warn("No _primaryColumns property in container, cell sizes won't be fixed.");
828828
}
829-
if (container["_primaryRows"]) {
829+
if (container["_primaryRows"] && container["_primaryCells"]) {
830830
for (i in container["_primaryRows"]) {
831-
columnHeights.push(container["_primaryRows"][i].offsetHeight);
831+
rowHeadersHeights.push(container["_primaryRows"][i].offsetHeight);
832+
}
833+
for (i in container["_primaryCells"]) {
834+
rowDataHeights.push(container["_primaryCells"][i].offsetHeight);
832835
}
833836
} else {
834837
console.warn("No _primaryRows property in container, cell sizes won't be fixed.");
@@ -902,14 +905,24 @@ PivotView.prototype.recalculateSizes = function (container) {
902905
if (tableTr.childNodes[i].tagName !== "TD") continue;
903906
tableTr.childNodes[i].style.width = cellWidths[i] + "px";
904907
}
905-
for (i in pTableHead.childNodes) {
906-
if (pTableHead.childNodes[i].tagName !== "TR") continue;
907-
if (pTableHead.childNodes[i].firstChild) {
908-
pTableHead.childNodes[i].firstChild.style.height =
909-
(columnHeights[i] || columnHeights[i - 1] || DEFAULT_CELL_HEIGHT)
910-
+ "px";
911-
}
912-
}
908+
//for (i in pTableHead.childNodes) {
909+
// if (pTableHead.childNodes[i].tagName !== "TR") continue;
910+
// if (pTableHead.childNodes[i].firstChild) {
911+
// pTableHead.childNodes[i].firstChild.style.height =
912+
// Math.max(
913+
// (rowHeadersHeights[i] || rowHeadersHeights[i - 1] || DEFAULT_CELL_HEIGHT),
914+
// (rowDataHeights[i] || rowDataHeights[i - 1] || DEFAULT_CELL_HEIGHT)
915+
// ) + "px";
916+
//
917+
// }
918+
//}
919+
container["_primaryRows"].forEach(function (val, i) {
920+
container["_primaryCells"][i].style.height =
921+
container["_primaryRows"][i].style.height = Math.max(
922+
rowHeadersHeights[i] || rowHeadersHeights[i - 1] || DEFAULT_CELL_HEIGHT,
923+
rowDataHeights[i] || rowDataHeights[i - 1] || DEFAULT_CELL_HEIGHT
924+
) + "px";
925+
});
913926

914927
// #keepSizes
915928
keepSizes.forEach(function (o) {
@@ -1071,8 +1084,8 @@ PivotView.prototype.renderRawData = function (data) {
10711084
})() : null,
10721085

10731086
renderedGroups = {}, // keys of rendered groups; key = group, value = { x, y, element }
1074-
i, x, y, tr = null, th, td, primaryColumns = [], primaryRows = [], ratio, cellStyle,
1075-
tempI, tempJ, div;
1087+
i, x, y, tr = null, th, td, primaryColumns = [], primaryRows = [], primaryCells = [],
1088+
ratio, cellStyle, tempI, tempJ, div;
10761089

10771090
this.SEARCH_ENABLED = SEARCH_ENABLED;
10781091

@@ -1273,7 +1286,7 @@ PivotView.prototype.renderRawData = function (data) {
12731286
}
12741287

12751288
// add listeners
1276-
if (vertical && x === xTo - 1 && !rawData[y][x]["noDrillDown"]) {
1289+
if (vertical && x === xTo - 1) {
12771290
primaryRows.push(th);
12781291
th.addEventListener(CLICK_EVENT, (function (index, data) {
12791292
return function () {
@@ -1360,6 +1373,7 @@ PivotView.prototype.renderRawData = function (data) {
13601373
cellStyle = this.controller.getPivotProperty(["cellStyle"]) || "";
13611374
tr.appendChild(td = document.createElement("td"));
13621375
td.appendChild(div = document.createElement("div"));
1376+
if (x === info.leftHeaderColumnsNumber) primaryCells.push(td);
13631377
formatContent(
13641378
rawData[y][x].value,
13651379
div,
@@ -1549,6 +1563,7 @@ PivotView.prototype.renderRawData = function (data) {
15491563

15501564
container["_primaryColumns"] = primaryColumns;
15511565
container["_primaryRows"] = primaryRows;
1566+
container["_primaryCells"] = primaryCells;
15521567
container["_listing"] = LISTING;
15531568

15541569
this.recalculateSizes(container);

0 commit comments

Comments
 (0)