Skip to content

Commit d020cca

Browse files
cell click handler, (fire) logs display option (default = false)
1 parent df4b661 commit d020cca

File tree

4 files changed

+20
-3
lines changed

4 files changed

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

readme.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ Then use global object constructed from <i>LightPivotTable</i>:
3636
var setup = { // Object that contain settings. Properties in brackets can be missed.
3737
container: document.getElementById("pivot") // HTMLElement which will contain table.
3838
[, locale: "en" ] // language to use (default: browser default or "en")
39+
logs: false, // enable logs
3940
, dataSource: {
4041
MDX2JSONSource: "http://localhost:57772/SAMPLES", // MDX2JSON server address
4142
basicMDX: typeof req === "object" ? req.basicMDX : req
@@ -54,6 +55,9 @@ var setup = { // Object that contain settings. Properties in brackets can be mis
5455
, responseHandler: function ({Object {url: {string}, status: {number}}}) {}
5556
, rowSelect: function ({Array}) {}
5657
, contentRendered: function () {}
58+
, cellSelected: function ({ x: Number, y: Number, leftHeaderColumnsNumber: Number, topHeaderRowsNumber: Number }) {
59+
return false; // return false to block default click action
60+
}
5761
} ]
5862
[ , pagination: 30 ] // Maximum rows number on one page (default: 200, turn off: 0)
5963
[ , hideButtons: true ] // hides "back" and "drillThrough" buttons

source/js/DataSource.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ DataSource.prototype.getCurrentData = function (callback) {
226226

227227
var requestData = function () {
228228

229-
console.log("LPT MDX request:", mdx);
229+
if (_.LPT.CONFIG["logs"]) console.log("LPT MDX request:", mdx);
230230

231231
_._post(
232232
_.SOURCE_URL + "/" +

source/js/PivotView.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ var PivotView = function (controller, container) {
5454
columnIndex: 0
5555
};
5656

57+
/**
58+
* @type {LightPivotTable}
59+
*/
5760
this.controller = controller;
5861

5962
this.SCROLLBAR_WIDTH = (function () {
@@ -428,12 +431,22 @@ PivotView.prototype._getSelectedText = function () {
428431
PivotView.prototype._cellClickHandler = function (cell, x, y, event, drillThroughHandler) {
429432

430433
var data = this.controller.dataController.getData(),
431-
f = [], f1, f2, callbackRes = true,
434+
f = [], f1, f2, callbackRes = true, result,
432435
ATTACH_TOTALS = this.controller.CONFIG["showSummary"]
433436
&& this.controller.CONFIG["attachTotals"] ? 1 : 0;
434437

435438
if (this._getSelectedText()) return; // exit if text in cell was selected
436439

440+
if (typeof this.controller.CONFIG.triggers["cellSelected"] === "function") {
441+
result = this.controller.CONFIG.triggers["cellSelected"].call(this.controller, {
442+
x: x - data.info.leftHeaderColumnsNumber,
443+
y: y - data.info.topHeaderRowsNumber,
444+
leftHeaderColumnsNumber: data.info.leftHeaderColumnsNumber,
445+
topHeaderRowsNumber: data.info.topHeaderRowsNumber
446+
});
447+
if (result === false) return;
448+
}
449+
437450
try {
438451
f1 = data.rawData[y][data.info.leftHeaderColumnsNumber - 1].source.path;
439452
f2 = data.rawData[data.info.topHeaderRowsNumber - 1 - ATTACH_TOTALS][x].source.path;

0 commit comments

Comments
 (0)