Skip to content

Commit aa19ac3

Browse files
value expand on drillThrough
1 parent 5e5ad43 commit aa19ac3

File tree

8 files changed

+37
-12
lines changed

8 files changed

+37
-12
lines changed

example/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@
9797
// drillDown: function ({Object { level: {number}, mdx: {string} }}) {}
9898
//, drillThrough: function ({Object { level: {number}, mdx: {string} }}) {}
9999
//, back: function ({Object { level: {number} }}) {}
100+
// if cellDrillThrough callback returns boolean false, DrillThrough won't be performed.
100101
//, cellDrillThrough: function ({Object { event: {event}, filters: {string[]} }}) {}
101102
}
102103
//, hideButtons: true // hides "back" and "drillThrough" buttons

gulpfile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ gulp.task("copyREADME", ["clean"], function (){
7171
gulp.task("exportCacheXML", [
7272
"clean", "addExample", "gatherScripts", "gatherCSS", "copyLICENSE", "copyREADME"
7373
], function () {
74-
return gulp.src("export/LightPivotTable.xml")
74+
return gulp.src("export/LightPivotTable-DeepSeePortlet.xml")
7575
.pipe(
7676
replace(/\{\{replace:css}}/,
7777
fs.readFileSync("build/WEBModule/css/lightPivotTable.css"))

readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ var setup = { // Object that contain settings. Any setting may be missed.
4747
, drillThrough: function ({Object { level: {number}, mdx: {string} }}) {}
4848
, back: function ({Object { level: {number} }}) {}
4949
// if cellDrillThrough callback returns boolean false, DrillThrough won't be performed.
50-
, cellDrillThrough: function ({Object { event: {event}, filters: {string[]} }}) {}
50+
, cellDrillThrough: function ({Object { event: {event}, filters: {string[]}, cellData: {object} }}) {}
5151
} ]
5252
[ , hideButtons: true // hides "back" and "drillThrough" buttons ]
5353
[ , triggerEvent: "touchstart" // all "click" events will be replaced by this event ]

source/css/LightPivot.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@
182182
.lpt .lpt-hoverMessage {
183183
z-index: 999;
184184
opacity: 0;
185-
background: rgba(255, 255, 255, 0.8);
185+
background: rgba(255, 255, 255, 0.85);
186186
-webkit-transition: opacity 1s ease;
187187
-moz-transition: opacity 1s ease;
188188
-o-transition: opacity 1s ease;

source/js/DataController.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,16 @@ DataController.prototype.setData = function (data) {
9595

9696
};
9797

98+
/**
99+
* Handle drillThrough on current level.
100+
* If handler returns boolean false, drillThrough won't be performed.
101+
*
102+
* @param {function} handler
103+
*/
104+
DataController.prototype.setDrillThroughHandler = function (handler) {
105+
this._dataStack[this._dataStack.length - 1].data.info.drillThroughHandler = handler;
106+
};
107+
98108
/**
99109
* Sets properties of rows/columns.
100110
*

source/js/LightPivotTable.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,10 @@ LightPivotTable.prototype.tryDrillThrough = function (filters) {
209209
_.pivotView.pushTable();
210210
_.dataController.pushData();
211211
_.dataController.setData(data);
212+
_.dataController.setDrillThroughHandler(function (params) {
213+
_.pivotView.displayMessage(params["cellData"]["value"] || "", true);
214+
return false;
215+
});
212216
if (typeof _.CONFIG.triggers["drillThrough"] === "function") {
213217
_.CONFIG.triggers["drillThrough"].call(_, {
214218
level: _.DRILL_LEVEL,

source/js/PivotView.js

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -191,14 +191,16 @@ PivotView.prototype._drillThroughClickHandler = function (event) {
191191
};
192192

193193
/**
194+
* @param {object} cell
194195
* @param {number} x
195196
* @param {number} y
196197
* @param {event} event
198+
* @param {function} [drillThroughHandler]
197199
*/
198-
PivotView.prototype._cellClickHandler = function (x, y, event) {
200+
PivotView.prototype._cellClickHandler = function (cell, x, y, event, drillThroughHandler) {
199201

200202
var data = this.controller.dataController.getData(),
201-
f = [], f1, f2, callbackRes;
203+
f = [], f1, f2, callbackRes = true;
202204

203205
try {
204206
f1 = data.rawData[y][data.info.leftHeaderColumnsNumber - 1].source.path;
@@ -218,12 +220,18 @@ PivotView.prototype._cellClickHandler = function (x, y, event) {
218220
if (typeof this.controller.CONFIG.triggers["cellDrillThrough"] === "function") {
219221
callbackRes = this.controller.CONFIG.triggers["cellDrillThrough"]({
220222
event: event,
221-
filters: f
223+
filters: f,
224+
cellData: cell
222225
});
223-
if (callbackRes !== false) this.controller.tryDrillThrough(f);
224-
} else {
225-
this.controller.tryDrillThrough(f);
226226
}
227+
if (typeof drillThroughHandler === "function") {
228+
callbackRes = !(!(false !== drillThroughHandler({
229+
event: event,
230+
filters: f,
231+
cellData: cell
232+
})) || !(callbackRes !== false));
233+
}
234+
if (callbackRes !== false) this.controller.tryDrillThrough(f);
227235
}
228236

229237
};
@@ -540,11 +548,13 @@ PivotView.prototype.renderRawData = function (data) {
540548
if (rawData[y][x].style) td.setAttribute("style", rawData[y][x].style);
541549

542550
// add handlers
543-
td.addEventListener("click", (function (x, y) {
551+
td.addEventListener("click", (function (x, y, cell) {
544552
return function (event) {
545-
_._cellClickHandler.call(_, x, y, event);
553+
_._cellClickHandler.call(
554+
_, cell, x, y, event, info.drillThroughHandler
555+
);
546556
};
547-
})(x, y));
557+
})(x, y, rawData[y][x]));
548558

549559
}
550560
mainTBody.appendChild(tr);

0 commit comments

Comments
 (0)