Skip to content

Commit 62196bc

Browse files
design & scrolling fixes
1 parent 0dfa980 commit 62196bc

4 files changed

Lines changed: 54 additions & 18 deletions

File tree

example/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
setup = {
8888
container: document.getElementById("pivot"), // HTMLElement which will contain table.
8989
dataSource: {
90-
MDX2JSONSource: "http://localhost:57772/SAMPLES", // MDX2JSON server address
90+
MDX2JSONSource: "http://192.168.1.101:57772/SAMPLES", // MDX2JSON server address
9191
basicMDX: typeof req === "object" ? req.basicMDX : req
9292
//[ , namespace: "SAMPLES" ] // current namespace : default namespace
9393
//[ , username: "USER" ] // user name : default user

source/css/LightPivot.css

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,15 @@
220220
background: #F0F0F0;
221221
}
222222

223+
.lpt .lpt-headerValue.back:hover {
224+
cursor: pointer;
225+
background: #FFF7D7;
226+
}
227+
.lpt .lpt-headerValue.back:before {
228+
content: "< ";
229+
font-weight: 900;
230+
}
231+
223232
/* new */
224233
.lpt .lpt-tableBlock table {
225234
table-layout: fixed;
@@ -230,38 +239,52 @@
230239
box-sizing: border-box;
231240
}
232241

233-
.lpt .tableContainer .lpt-topSection, .lpt .tableContainer .lpt-bottomSection {
242+
.lpt .lpt-topSection, .lpt .lpt-bottomSection {
234243
position: relative;
235-
overflow: hidden;
236244
}
237245

238-
.lpt .tableContainer .lpt-header {
246+
.lpt .lpt-header {
239247
display: table;
240248
position: relative;
241249
float: left;
250+
z-index: 2;
251+
box-shadow: 0 0 0 1px rgb(208, 208, 208);
252+
white-space: nowrap;
242253
/*width: 100px;*/
243254
}
244255

245-
.lpt .tableContainer .lpt-topHeader {
256+
.lpt .lpt-topHeader {
246257
position: relative;
247258
overflow: hidden;
259+
z-index: 1;
260+
box-shadow: 0 0 0 1px rgb(208, 208, 208);
248261
/*margin-left: 100px;*/
249262
}
250263

251-
.lpt .tableContainer .lpt-leftHeader {
264+
.lpt .lpt-leftHeader {
252265
position: relative;
253266
overflow: hidden;
254267
float: left;
255268
/*width: 100px;*/
256269
}
257270

258-
.lpt .tableContainer .lpt-tableBlock {
271+
.lpt .lpt-leftHeader.bordered {
272+
z-index: 1;
273+
box-shadow: 0 0 0 1px rgb(208, 208, 208);
274+
}
275+
276+
.lpt .lpt-leftHeader th:last-child:hover {
277+
cursor: pointer;
278+
background: #FFF7D7;
279+
}
280+
281+
.lpt .lpt-tableBlock {
259282
position: relative;
260283
overflow: auto;
261284
/*margin-left: 100px;*/
262285
}
263286

264-
.lpt .tableContainer .lpt-headerValue {
287+
.lpt .lpt-headerValue {
265288
display: table-cell;
266289
font-weight: bold;
267290
border-right: none;
@@ -278,11 +301,11 @@
278301
/*border-top: none;*/
279302
/*}*/
280303

281-
.lpt .tableContainer .lpt-leftHeader th {
304+
.lpt .lpt-leftHeader th {
282305
border-right: none;
283306
}
284307

285-
.lpt .tableContainer .lpt-topHeader th {
308+
.lpt .lpt-topHeader th {
286309
border-bottom: none;
287310
}
288311

source/js/DataController.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ DataController.prototype.resetRawData = function () {
310310
: countSummaryByColumn)(rawData, xh, rawData.length - 1, i),
311311
// end
312312
//value: (countSummaryByColumn)(rawData, xh, rawData.length - 1, i),
313-
style: "font-weight: 900;"
313+
style: "font-weight: bold;"
314314
}
315315
}
316316
}

source/js/PivotView.js

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -435,8 +435,6 @@ PivotView.prototype.recalculateSizes = function (container) {
435435
addExtraLeftHeaderCell = lTableHead.offsetHeight > containerHeight - headerH,
436436
cell, cellWidths = [], i;
437437

438-
console.log( lTableHead.offsetHeight, leftHeader.offsetHeight);
439-
440438
headerContainer.style.width = headerW + "px";
441439
for (i in topTableTr.childNodes) {
442440
if (tableTr.childNodes[i].tagName !== "TD") continue;
@@ -457,11 +455,11 @@ PivotView.prototype.recalculateSizes = function (container) {
457455
cell.style.paddingLeft = headerW + "px"; // lucky random
458456
}
459457

460-
console.log(addExtraLeftHeaderCell);
461458
if (addExtraLeftHeaderCell) {
462459
lTableHead.appendChild(
463460
document.createElement("tr").appendChild(cell = document.createElement("th"))
464461
);
462+
leftHeader.className = "lpt-leftHeader bordered";
465463
cell.colSpan = lTableHead.childNodes.length;
466464
cell.style.paddingTop = headerH + "px"; // lucky random
467465
}
@@ -497,7 +495,8 @@ PivotView.prototype.renderRawData = function (data) {
497495

498496
this.removeMessage();
499497

500-
var CLICK_EVENT = this.controller.CONFIG["triggerEvent"] || "click",
498+
var _ = this,
499+
CLICK_EVENT = this.controller.CONFIG["triggerEvent"] || "click",
501500
renderedGroups = {}, // keys of rendered groups; key = group, value = { x, y, element }
502501
rawData = data["rawData"],
503502
info = data["info"],
@@ -518,7 +517,7 @@ PivotView.prototype.renderRawData = function (data) {
518517
x, y, tr = null, th, td;
519518

520519
var renderHeader = function (xFrom, xTo, yFrom, yTo, targetElement) {
521-
var vertical = targetElement === LHTable;
520+
var vertical = targetElement === LHTHead;
522521
for (y = yFrom; y < yTo; y++) {
523522
for (x = xFrom; x < xTo; x++) {
524523
if (renderedGroups.hasOwnProperty(rawData[y][x].group)) { // recalculate c/r 'span
@@ -530,6 +529,13 @@ PivotView.prototype.renderRawData = function (data) {
530529
if (!tr) tr = document.createElement("tr");
531530
tr.appendChild(th = document.createElement("th"));
532531
th.textContent = rawData[y][x].value;
532+
if (vertical && x === xTo - 1) {
533+
th.addEventListener(CLICK_EVENT, (function (index, data) {
534+
return function () {
535+
_._rowClickHandler.call(_, index, data);
536+
};
537+
})(y, rawData[y][x]));
538+
}
533539
if (rawData[y][x].group) renderedGroups[rawData[y][x].group] = {
534540
x: x,
535541
y: y,
@@ -546,6 +552,12 @@ PivotView.prototype.renderRawData = function (data) {
546552

547553
// fill header
548554
header.textContent = rawData[0][0].value;
555+
if (this.tablesStack.length > 1 && !this.controller.CONFIG["hideButtons"]) {
556+
header.className += "back ";
557+
header.addEventListener(CLICK_EVENT, function (e) {
558+
_._backClickHandler.call(_, e);
559+
});
560+
}
549561

550562
// render topHeader
551563
renderHeader(
@@ -571,6 +583,7 @@ PivotView.prototype.renderRawData = function (data) {
571583
for (x = info.leftHeaderColumnsNumber; x < rawData[0].length; x++) {
572584
tr.appendChild(td = document.createElement("td"));
573585
td.textContent = rawData[y][x].value || "";
586+
if (rawData[y][x].style) td.setAttribute("style", rawData[y][x].style);
574587
}
575588
mainTBody.appendChild(tr);
576589
}
@@ -586,7 +599,7 @@ PivotView.prototype.renderRawData = function (data) {
586599
pivotHeader.className = "lpt-header";
587600
pivotTopSection.className = "lpt-topSection";
588601
pivotBottomSection.className = "lpt-bottomSection";
589-
header.className = "lpt-headerValue";
602+
header.className += "lpt-headerValue";
590603
mainTable.appendChild(mainTBody);
591604
tableBlock.appendChild(mainTable);
592605
LHTable.appendChild(LHTHead);
@@ -790,4 +803,4 @@ PivotView.prototype.renderRawData = function (data) {
790803
// this.elements.tableContainer.appendChild(table);
791804
// this.fixHeaders(table);
792805
//
793-
//};
806+
//};

0 commit comments

Comments
 (0)