Skip to content

Commit e16903d

Browse files
maximum header width setting
1 parent 97c9f41 commit e16903d

File tree

6 files changed

+37
-8
lines changed

6 files changed

+37
-8
lines changed

example/index.html

+2-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@
116116
//, conditionalFormattingOn: true // enable conditional formatting rules
117117
//, defaultFilterSpecs: ["[Date].[H1].[month].&[]"] ] // default filters array
118118
//, drillDownTarget: "<dashboard name>" // undocumented, deepSee only
119-
, listingColumnMinWidth: 200 // minimal width of column in listing
119+
//, listingColumnMinWidth: 200 // minimal width of column in listing
120+
//, maxHeaderWidth: 100 // maximum width of header
120121
};
121122

122123
if (req.DrillDownExpression) { // set custom DrillDown on variant 10

export/LightPivotTable-DeepSeePortlet.xml

+10-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
<Class name="DeepSee.LightPivotTable">
1313
<Super>%DeepSee.Component.Portlet.abstractPortlet</Super>
14-
<TimeChanged>63575,78017.533889</TimeChanged>
14+
<TimeChanged>63575,80028.98656</TimeChanged>
1515
<TimeCreated>63515,61322.546099</TimeCreated>
1616

1717
<Parameter name="INCLUDEFILES">
@@ -42,6 +42,10 @@
4242
<Type>%Integer</Type>
4343
</Property>
4444

45+
<Property name="MaxHeaderWidth">
46+
<Type>%Integer</Type>
47+
</Property>
48+
4549
<Method name="%OnGetPortletName">
4650
<ClassMethod>1</ClassMethod>
4751
<ReturnType>%String</ReturnType>
@@ -69,6 +73,7 @@
6973
set pInfo($I(pInfo)) = $LB("Pagination", 0, "%Integer", $$$Text("Pagination", "%DeepSee"), "Enable pagination")
7074
set pInfo($I(pInfo)) = $LB("FixTotals", 0, "%Boolean", $$$Text("Fix totals", "%DeepSee"), "Fix totals in header")
7175
set pInfo($I(pInfo)) = $LB("ListingColumnMinWidth", 0, "%Integer", $$$Text("Min cell width for listing", "%DeepSee"), "Minimal column width in listing")
76+
set pInfo($I(pInfo)) = $LB("MaxHeaderWidth", 0, "%Integer", $$$Text("Max column width", "%DeepSee"), "Maximal column width for headers")
7277
7378
quit $$$OK
7479
]]></Implementation>
@@ -249,6 +254,9 @@
249254
if (parseInt(container.getAttribute("listingColumnMinWidth"))) {
250255
setup["listingColumnMinWidth"] = parseInt(container.getAttribute("listingColumnMinWidth"))
251256
}
257+
if (parseInt(container.getAttribute("maxHeaderWidth"))) {
258+
setup["maxHeaderWidth"] = parseInt(container.getAttribute("maxHeaderWidth"))
259+
}
252260
253261
_.LightPivotTable = new LightPivotTable(setup);
254262
@@ -345,7 +353,7 @@
345353
}
346354
347355
&html<
348-
<div listingColumnMinWidth="#(..ListingColumnMinWidth)#" fixTotals="#(..FixTotals)#" pagination="#(..Pagination)#" export-csv="#(..ExportCSV)#" data-source="#(..DataSource)#" show-summary="#(..ShowSummary)#" class="lpt-container" style="position: absolute; left: 0; bottom: 0; width: 100%; height: 100%;">
356+
<div maxHeaderWidth="#(..MaxHeaderWidth)#" listingColumnMinWidth="#(..ListingColumnMinWidth)#" fixTotals="#(..FixTotals)#" pagination="#(..Pagination)#" export-csv="#(..ExportCSV)#" data-source="#(..DataSource)#" show-summary="#(..ShowSummary)#" class="lpt-container" style="position: absolute; left: 0; bottom: 0; width: 100%; height: 100%;">
349357
350358
</div>
351359
>

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "LightPivotTable",
33
"author": "ZitRo",
4-
"version": "1.0.0-beta.5",
4+
"version": "1.0.0-beta.6",
55
"description": "A lightweight pivot table for MDX2JSON source for InterSystems Cache",
66
"main": "test/testServer.js",
77
"repository": {

readme.md

+2
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ var setup = { // Object that contain settings. Any setting may be missed.
6363
[ , enableHeadersScrolling: false ] // enable scrolling both for table and headers. Useful for mobile devices.
6464
[ , defaultFilterSpecs: ["[Date].[H1].[month].&[]"] ] // default filters array
6565
[ , drillDownTarget: "<dashboard name>" ] // deepSee only - dashboard to open
66+
[ , listingColumnMinWidth: 200 ] // minimal width of column in listing
67+
[ , maxHeaderWidth: 100 ] // maximum width of header
6668
},
6769
lp = new LightPivotTable(setup);
6870

source/css/LightPivot.css

+1
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@
8989
.lpt th, .lpt td {
9090
white-space: pre;
9191
box-sizing: border-box;
92+
overflow: hidden;
9293
}
9394

9495
.lpt .lpt-tableBlock td {

source/js/PivotView.js

+21-4
Original file line numberDiff line numberDiff line change
@@ -465,13 +465,15 @@ PivotView.prototype.recalculateSizes = function (container) {
465465
}
466466

467467
var pagedHeight = this.pagination.on ? this.PAGINATION_BLOCK_HEIGHT : 0,
468-
headerW = leftHeader.offsetWidth,
468+
headerW = Math.max(leftHeader.offsetWidth, headerContainer.offsetWidth),
469469
headerH = topHeader.offsetHeight,
470470
containerHeight = container.offsetHeight,
471471
bodyHeight = containerHeight - headerH - pagedHeight,
472472
mainHeaderWidth = headerContainer.offsetWidth,
473-
hasVerticalScrollBar = lTableHead.offsetHeight > bodyHeight
473+
hasVerticalScrollBar =
474+
Math.max(lTableHead.offsetHeight, pTableHead.offsetHeight) > bodyHeight
474475
&& this.SCROLLBAR_WIDTH > 0,
476+
addEggs = hasVerticalScrollBar && lTableHead.offsetHeight > 0,
475477
cell, tr, cellWidths = [], columnHeights = [], i;
476478

477479
headerContainer.style.width = headerW + "px";
@@ -517,7 +519,7 @@ PivotView.prototype.recalculateSizes = function (container) {
517519
container["_primaryColumns"][i].style.width = cellWidths[i] + "px";
518520
}
519521

520-
if (hasVerticalScrollBar) { // horScroll?
522+
if (addEggs) { // horScroll?
521523
tr = document.createElement("tr");
522524
tr.appendChild(cell = document.createElement("th"));
523525
lTableHead.appendChild(tr);
@@ -668,12 +670,20 @@ PivotView.prototype.renderRawData = function (data) {
668670
tr.appendChild(
669671
th = document.createElement(rawData[y][x].isCaption ? "th" : "td")
670672
);
671-
th.textContent = rawData[y][x].value || " ";
673+
if (rawData[y][x].value) {
674+
th.textContent = rawData[y][x].value;
675+
} else th.innerHTML = "&zwnj;";
672676
if (rawData[y][x].style) th.setAttribute("style", rawData[y][x].style);
673677
if (info.leftHeaderColumnsNumber === 0
674678
&& _.controller.CONFIG["listingColumnMinWidth"]) { // if listing
675679
th.style.minWidth = _.controller.CONFIG["listingColumnMinWidth"] + "px";
676680
}
681+
if (info.leftHeaderColumnsNumber > 0
682+
&& _.controller.CONFIG["maxHeaderWidth"]) {
683+
th.style.maxWidth = _.controller.CONFIG["maxHeaderWidth"] + "px";
684+
th.style.whiteSpace = "normal";
685+
th.style.wordWrap = "normal";
686+
}
677687
if (rawData[y][x].className) th.className = rawData[y][x].className;
678688
if (rawData[y][x].group) renderedGroups[rawData[y][x].group] = {
679689
x: x,
@@ -727,6 +737,13 @@ PivotView.prototype.renderRawData = function (data) {
727737
_._backClickHandler.call(_, e);
728738
});
729739
}
740+
if (info.leftHeaderColumnsNumber > 0
741+
&& _.controller.CONFIG["maxHeaderWidth"]) {
742+
pivotHeader.style.maxWidth =
743+
_.controller.CONFIG["maxHeaderWidth"]*info.leftHeaderColumnsNumber + "px";
744+
pivotHeader.style.whiteSpace = "normal";
745+
pivotHeader.style.wordWrap = "normal";
746+
}
730747
if ( // hide unnecessary column
731748
(this.controller.CONFIG["hideButtons"] || this.tablesStack.length < 2)
732749
&& info.leftHeaderColumnsNumber === 0

0 commit comments

Comments
 (0)