Skip to content

Commit ee599c8

Browse files
formatting for headers apply - partly implemented
1 parent b584705 commit ee599c8

File tree

2 files changed

+15
-7
lines changed

2 files changed

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

source/js/DataController.js

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -374,21 +374,25 @@ DataController.prototype.resetRawData = function () {
374374
if (!_.controller.CONFIG["pivotProperties"]) return rawData;
375375
var x, y, i, xEnd = rawData[0].length,
376376
colLevels = _.controller.getPivotProperty(["columnLevels"]),
377+
rowLevels = _.controller.getPivotProperty(["rowLevels"]),
377378
formatColumn = {
378379
// "<spec>": { style: "<style>" }
379380
};
380381
var fillLevels = function (obj) {
381382
if (typeof obj === "undefined") return;
382383
for (var i in obj["childLevels"]) {
383-
if (obj["childLevels"][i]["spec"] && obj["childLevels"][i]["levelStyle"]) {
384-
formatColumn[obj["childLevels"][i]["spec"]] =
385-
{ style: obj["childLevels"][i]["levelStyle"] };
384+
if (obj["childLevels"][i] && obj["childLevels"][i]["spec"]) {
385+
formatColumn[(obj["childLevels"][i]["spec"] || "").replace(/[^.]*$/, "")] = {
386+
style: obj["childLevels"][i]["levelStyle"] || "",
387+
headStyle: obj["childLevels"][i]["levelHeaderStyle"] || ""
388+
};
386389
}
387390
fillLevels(obj["childLevels"][i]);
388391
}
389392
};
390393
for (i in colLevels) {
391-
fillLevels(colLevels[i]);
394+
fillLevels({ childLevels: [colLevels[i]] });
395+
fillLevels({ childLevels: [rowLevels[i]] });
392396
}
393397
for (y = 0; y < rawData.length; y++) {
394398
for (x = 0; x < xEnd; x++) {
@@ -398,10 +402,14 @@ DataController.prototype.resetRawData = function () {
398402
if (rawData[y][x].source && rawData[y][x].source["path"]) {
399403
for (i in formatColumn) {
400404
if (rawData[y][x].source["path"].indexOf(i) >= 0) {
401-
for (var yy = y + 1; yy < rawData.length; yy++) {
405+
var yy;
406+
for (yy = y; yy < rawData.length; yy++) {
402407
if (!rawData[yy][x].isCaption) {
403-
rawData[yy][x].style = (rawData[yy][x].style || "")
408+
if (formatColumn[i].style) rawData[yy][x].style = (rawData[yy][x].style || "")
404409
+ formatColumn[i].style || "";
410+
} else {
411+
if (formatColumn[i].headStyle) rawData[yy][x].style = (rawData[yy][x].style || "")
412+
+ formatColumn[i].headStyle || "";
405413
}
406414
}
407415
break;

0 commit comments

Comments
 (0)