From a17c0b54425b07a4e8b8150e4d3b67da1ab42458 Mon Sep 17 00:00:00 2001 From: ZitRos Date: Wed, 3 Dec 2014 23:30:26 +0200 Subject: [PATCH] custom DrillDown on higher levels support --- export/LightPivotTable.xml | 5 ++--- source/js/LightPivotTable.js | 11 +++++++++-- source/js/PivotView.js | 2 +- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/export/LightPivotTable.xml b/export/LightPivotTable.xml index 5639e42..29e0bf0 100644 --- a/export/LightPivotTable.xml +++ b/export/LightPivotTable.xml @@ -11,7 +11,7 @@ %DeepSee.Component.Portlet.abstractPortlet - 63524,69651.14693 + 63524,83748.41729 63515,61322.546099 @@ -187,8 +187,7 @@ //console.log(data); if (data["rowAxisOptions"]) { if (data["rowAxisOptions"]["drilldownSpec"]) { - console.log(data["rowAxisOptions"]["drilldownSpec"]); - setup.DrillDownExpression = data["rowAxisOptions"]["drilldownSpec"]; + setup.DrillDownExpression = data["rowAxisOptions"]["drilldownSpec"].split("^"); } if (data["rowAxisOptions"]["levelFormat"] || data["columnAxisOptions"] && data["columnAxisOptions"]["levelFormat"]) { setup["formatNumbers"] = data["columnAxisOptions"]["levelFormat"] || data["rowAxisOptions"]["levelFormat"]; diff --git a/source/js/LightPivotTable.js b/source/js/LightPivotTable.js index afec82a..65ada08 100644 --- a/source/js/LightPivotTable.js +++ b/source/js/LightPivotTable.js @@ -12,6 +12,7 @@ var LightPivotTable = function (configuration) { this._dataSourcesStack = []; + this.DRILL_LEVEL = -1; this.CONFIG = configuration; this.mdxParser = new MDXParser(); @@ -84,6 +85,7 @@ LightPivotTable.prototype.pushDataSource = function (config) { var newDataSource; + this.DRILL_LEVEL++; this._dataSourcesStack.push(newDataSource = new DataSource(config)); this.dataSource = newDataSource; @@ -95,6 +97,7 @@ LightPivotTable.prototype.popDataSource = function () { if (this._dataSourcesStack.length < 2) return; + this.DRILL_LEVEL--; this._dataSourcesStack.pop(); this.dataController.popData(); @@ -125,9 +128,13 @@ LightPivotTable.prototype.tryDrillDown = function (filter) { // clone dataSource config object for (var i in _.CONFIG.dataSource) { ds[i] = _.CONFIG.dataSource[i]; } - if (this.CONFIG.DrillDownExpression && this._dataSourcesStack.length < 2) { + if (this.CONFIG.DrillDownExpression && !(this.CONFIG.DrillDownExpression instanceof Array)) { + this.CONFIG.DrillDownExpression = [this.CONFIG.DrillDownExpression]; + } + + if ((this.CONFIG.DrillDownExpression || [])[this.DRILL_LEVEL]) { ds.basicMDX = this.mdxParser.drillDown( - this.dataSource.BASIC_MDX, filter, this.CONFIG.DrillDownExpression + this.dataSource.BASIC_MDX, filter, this.CONFIG.DrillDownExpression[this.DRILL_LEVEL] ) || this.dataSource.BASIC_MDX; } else { ds.basicMDX = this.mdxParser.drillDown(this.dataSource.BASIC_MDX, filter) || this.dataSource.BASIC_MDX; diff --git a/source/js/PivotView.js b/source/js/PivotView.js index c54bba3..545728a 100644 --- a/source/js/PivotView.js +++ b/source/js/PivotView.js @@ -501,7 +501,7 @@ PivotView.prototype.renderRawData = function (data) { td.className = "formatLeft"; } if (data[y][x].style) { - for (i in data[y][x].style) { + for (var i in data[y][x].style) { td.style[i] = data[y][x].style[i]; } }