Skip to content

Commit e52f4b2

Browse files
Listing row selection now highlights the row
1 parent 23c440e commit e52f4b2

File tree

3 files changed

+31
-4
lines changed

3 files changed

+31
-4
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.4.3",
4+
"version": "1.4.4",
55
"description": "A lightweight pivot table for MDX2JSON source for InterSystems Cache",
66
"main": "test/testServer.js",
77
"repository": {

source/css/LightPivot.css

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,16 @@
5151
transition: left .5s ease;
5252
}
5353

54+
.lpt input[type=checkbox] {
55+
cursor: pointer;
56+
}
57+
5458
.lpt .lpt-tableBlock tr:hover td {
55-
box-shadow: inset 0 0 30px #FFF7D7;
59+
box-shadow: inset 0 0 30px #fff5b9;
5660
}
5761

5862
.lpt .lpt-tableBlock table td:hover {
59-
box-shadow: inset 0 0 30px #FEA;
63+
box-shadow: inset 0 0 30px #fff16c;
6064
}
6165

6266
/* DeepSee theme */
@@ -427,6 +431,10 @@
427431
pointer-events: none;
428432
}
429433

434+
.lpt-selectedRow td {
435+
box-shadow: inset 0 0 30px #fff5b9;
436+
}
437+
430438
.lpt-searchSelectOuter select {
431439
font-size: 13px;
432440
padding: 0 0 0 2px;

source/js/PivotView.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1061,21 +1061,40 @@ PivotView.prototype.renderRawData = function (data) {
10611061
var vertical = targetElement === LHTHead,
10621062
rendered, separatelyGrouped, tr, th, div, checkbox;
10631063

1064+
function applySelect (element) { // checkbox element
1065+
var checked = element.checked;
1066+
while (element = element.parentNode) {
1067+
if (element.tagName === "TR") {
1068+
element.classList[checked ? "add" : "remove"]("lpt-selectedRow");
1069+
_.elements.tableContainer.querySelector(".lpt-tableBlock table")
1070+
.rows[element.rowIndex]
1071+
.classList[checked ? "add" : "remove"]("lpt-selectedRow");
1072+
break;
1073+
}
1074+
}
1075+
}
1076+
10641077
if (xFrom === xTo && LISTING_SELECT_ENABLED) { // listing
10651078
for (y = yFrom; y < yTo; y++) {
10661079
tr = document.createElement("tr");
10671080
th = document.createElement("td");
10681081
checkbox = document.createElement("input");
10691082
checkbox.setAttribute("type", "checkbox");
10701083
checkbox.checked = !!_.selectedRows[y];
1084+
if (checkbox.checked) (function (checkbox) {
1085+
setTimeout(function () { // highlight the rows after html generated
1086+
applySelect(checkbox);
1087+
}, 1);
1088+
})(checkbox);
10711089
th.setAttribute("style", "padding: 0 !important;");
10721090
checkbox.addEventListener("click", (function (y) { return function (e) {
10731091
var element = e.srcElement || e.target;
10741092
e.preventDefault();
10751093
e.cancelBubble = true;
1076-
setTimeout(function () { // bad, but only working workaround for ISC DeepSee
1094+
setTimeout(function () { // bad, but the only working workaround for ISC DeepSee
10771095
element.checked = !element.checked;
10781096
_.selectRow.call(_, element.checked, y);
1097+
applySelect(element);
10791098
}, 1);
10801099
}})(y));
10811100
th.appendChild(checkbox);

0 commit comments

Comments
 (0)