Skip to content

Commit 034a885

Browse files
column stretching option disabling that fixes clearly column sizes problems
1 parent f5bc548 commit 034a885

File tree

5 files changed

+44
-9
lines changed

5 files changed

+44
-9
lines changed

example/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@
130130
//, maxHeaderWidth: 100 // maximum width of header
131131
//, columnResizing: true // make columns resizable (default: true)
132132
//, enableSearch: false // enables search panel in listing
133+
//, stretchColumns: true // stretch columns to fill all available width (default: true)
133134
};
134135

135136
var e;

export/LightPivotTable-DeepSeePortlet.xml

Lines changed: 8 additions & 2 deletions
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>63605,62749.080977</TimeChanged>
14+
<TimeChanged>63606,42413.124862</TimeChanged>
1515
<TimeCreated>63515,61322.546099</TimeCreated>
1616

1717
<Parameter name="INCLUDEFILES">
@@ -54,6 +54,10 @@
5454
<Type>%Boolean</Type>
5555
</Property>
5656

57+
<Property name="StretchColumns">
58+
<Type>%Boolean</Type>
59+
</Property>
60+
5761
<Method name="%OnGetPortletName">
5862
<ClassMethod>1</ClassMethod>
5963
<ReturnType>%String</ReturnType>
@@ -84,6 +88,7 @@
8488
set pInfo($I(pInfo)) = $LB("MaxHeaderWidth", 0, "%Integer", "Max column width", "Maximal column width for headers")
8589
set pInfo($I(pInfo)) = $LB("ColumnResizing", 1, "%Boolean", "Column resizing", "Allow resizing columns with cursor")
8690
set pInfo($I(pInfo)) = $LB("EnableSearch", 1, "%Boolean", "Enable listing search", "Show search tools in listing mode")
91+
set pInfo($I(pInfo)) = $LB("StretchColumns", 0, "%Boolean", "Stretch columns", "Stretch columns to fill all available width")
8792
8893
quit $$$OK
8994
]]></Implementation>
@@ -260,6 +265,7 @@
260265
setup["attachTotals"] = !!parseInt(container.getAttribute("fixTotals"));
261266
setup["columnResizing"] = !!parseInt(container.getAttribute("columnResizing"));
262267
setup["enableSearch"] = !!parseInt(container.getAttribute("enableSearch"));
268+
setup["stretchColumns"] = !!parseInt(container.getAttribute("stretchColumns"));
263269
if (parseInt(container.getAttribute("pagination"))) {
264270
setup["pagination"] = parseInt(container.getAttribute("pagination"))
265271
}
@@ -396,7 +402,7 @@
396402
}
397403
398404
&html<
399-
<div namespace="#($NAMESPACE)#" enableSearch="#(..EnableSearch)#" columnResizing="#(..ColumnResizing)#" session="#(%session.CSPSessionCookie)#" maxHeaderWidth="#(..MaxHeaderWidth)#" listingColumnMinWidth="#(..ListingColumnMinWidth)#" fixTotals="#(..FixTotals)#" pagination="#(..Pagination)#" export-csv="#(..ExportCSV)#" data-source="#(..DataSourceApp)#" show-summary="#(..ShowSummary)#" class="lpt-container" style="position: absolute; left: 0; bottom: 0; width: 100%; height: 100%;">
405+
<div stretchColumns="#(..StretchColumns)#" namespace="#($NAMESPACE)#" enableSearch="#(..EnableSearch)#" columnResizing="#(..ColumnResizing)#" session="#(%session.CSPSessionCookie)#" maxHeaderWidth="#(..MaxHeaderWidth)#" listingColumnMinWidth="#(..ListingColumnMinWidth)#" fixTotals="#(..FixTotals)#" pagination="#(..Pagination)#" export-csv="#(..ExportCSV)#" data-source="#(..DataSourceApp)#" show-summary="#(..ShowSummary)#" class="lpt-container" style="position: absolute; left: 0; bottom: 0; width: 100%; height: 100%;">
400406
401407
</div>
402408
>

package.json

Lines changed: 5 additions & 2 deletions
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.13",
4+
"version": "1.0.0-beta.14",
55
"description": "A lightweight pivot table for MDX2JSON source for InterSystems Cache",
66
"main": "test/testServer.js",
77
"repository": {
@@ -30,5 +30,8 @@
3030
"data",
3131
"collection",
3232
"visualization"
33-
]
33+
],
34+
"dependencies": {
35+
"gulp-header": "^1.2.2"
36+
}
3437
}

source/js/LightPivotTable.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,7 @@ LightPivotTable.prototype.normalizeConfiguration = function (config) {
298298
if (typeof config["columnResizing"] === "undefined") config.columnResizing = true;
299299
if (typeof config["pagination"] === "undefined") config.pagination = 200;
300300
if (typeof config["enableSearch"] === "undefined") config.enableSearch = true;
301+
if (typeof config["stretchColumns"] === "undefined") config.stretchColumns = true;
301302
if (!config["triggers"]) config.triggers = {};
302303
if (!config["dataSource"]) config.dataSource = {};
303304
};

source/js/PivotView.js

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -504,10 +504,12 @@ PivotView.prototype.recalculateSizes = function (container) {
504504

505505
var headerContainer = container.getElementsByClassName("lpt-header")[0],
506506
topHeader = container.getElementsByClassName("lpt-topHeader")[0],
507+
topHeaderTable = container.getElementsByTagName("table")[0],
507508
tTableHead = topHeader.getElementsByTagName("thead")[0],
508509
leftHeader = container.getElementsByClassName("lpt-leftHeader")[0],
509510
lTableHead = leftHeader.getElementsByTagName("thead")[0],
510511
tableBlock = container.getElementsByClassName("lpt-tableBlock")[0],
512+
mainContentTable = tableBlock.getElementsByTagName("table")[0],
511513
pTableHead = tableBlock.getElementsByTagName("tbody")[0],
512514
searchInput = container.getElementsByClassName("lpt-searchInput")[0],
513515
searchInputSize = searchInput ? container.offsetWidth - this.SEARCHBOX_LEFT_MARGIN : 0,
@@ -523,19 +525,35 @@ PivotView.prototype.recalculateSizes = function (container) {
523525
var pagedHeight = (this.pagination.on ? this.PAGINATION_BLOCK_HEIGHT : 0)
524526
+ (this.SEARCH_ENABLED ? this.PAGINATION_BLOCK_HEIGHT : 0),
525527
headerW = Math.max(leftHeader.offsetWidth, headerContainer.offsetWidth),
526-
headerH = topHeader.offsetHeight,
527-
containerHeight = container.offsetHeight,
528+
headerH = topHeader.offsetHeight;
529+
530+
topHeader.style.marginLeft = headerW + "px";
531+
532+
var containerHeight = container.offsetHeight,
528533
bodyHeight = containerHeight - headerH - pagedHeight,
529534
mainHeaderWidth = headerContainer.offsetWidth,
530535
IS_LISTING = lTableHead.offsetHeight === 0,
531536
hasVerticalScrollBar =
532537
Math.max(lTableHead.offsetHeight, pTableHead.offsetHeight) > bodyHeight
533538
&& this.SCROLLBAR_WIDTH > 0,
534-
addEggs = hasVerticalScrollBar && !IS_LISTING,
539+
hasHorizontalScrollBar =
540+
tTableHead.offsetWidth >
541+
topHeader.offsetWidth - (hasVerticalScrollBar ? this.SCROLLBAR_WIDTH : 0);
542+
543+
// horizontal scroll bar may change vertical scroll bar, so we need recalculate
544+
if (!hasVerticalScrollBar && hasHorizontalScrollBar) {
545+
hasVerticalScrollBar =
546+
Math.max(lTableHead.offsetHeight, pTableHead.offsetHeight) > bodyHeight - this.SCROLLBAR_WIDTH
547+
&& this.SCROLLBAR_WIDTH > 0;
548+
}
549+
550+
var addEggs = hasVerticalScrollBar && !IS_LISTING,
535551
cell, tr, cellWidths = [], columnHeights = [], i,
536552
headerCellApplied = false;
537553

538554
var applyExtraTopHeadCell = function () {
555+
if (!_.controller.CONFIG.stretchColumns &&
556+
hasVerticalScrollBar && !hasHorizontalScrollBar) return;
539557
headerCellApplied = true;
540558
tr = document.createElement("th");
541559
tr.className = "lpt-extraCell";
@@ -546,7 +564,6 @@ PivotView.prototype.recalculateSizes = function (container) {
546564
tTableHead.childNodes[0].appendChild(tr);
547565
};
548566

549-
topHeader.style.marginLeft = headerW + "px";
550567
//return;
551568
//console.log(lTableHead.offsetHeight, pTableHead.offsetHeight, bodyHeight, this.SCROLLBAR_WIDTH);
552569
if (hasVerticalScrollBar && tTableHead.childNodes[0]) {
@@ -578,6 +595,10 @@ PivotView.prototype.recalculateSizes = function (container) {
578595
tableBlock.style.height = containerHeight - headerH - pagedHeight + "px";
579596
headerContainer.style.height = headerH + "px";
580597
headerContainer.style.width = headerW + "px";
598+
if (!this.controller.CONFIG.stretchColumns) {
599+
topHeaderTable.style.width = "auto";
600+
mainContentTable.style.width = hasHorizontalScrollBar ? "100%" : "auto";
601+
}
581602

582603
// @TEST beta.13
583604
//for (i in container["_primaryRows"]) {
@@ -1006,7 +1027,7 @@ PivotView.prototype.renderRawData = function (data) {
10061027
data["conditionalFormatting"],
10071028
(y - info.topHeaderRowsNumber + 1) + "," + (x - info.leftHeaderColumnsNumber + 1),
10081029
rawData[y][x].value,
1009-
td
1030+
div
10101031
);
10111032
}
10121033

@@ -1066,6 +1087,9 @@ PivotView.prototype.renderRawData = function (data) {
10661087
pivotBottomSection.appendChild(tableBlock);
10671088
container.appendChild(pivotTopSection);
10681089
container.appendChild(pivotBottomSection);
1090+
if (!this.controller.CONFIG.stretchColumns) {
1091+
THTable.style.width = "auto"; // required for correct 1st resizing
1092+
}
10691093

10701094
if (pageSwitcher) {
10711095
pageSwitcher.className = "lpt-pageSwitcher";

0 commit comments

Comments
 (0)