diff --git a/package.json b/package.json index 67c3b23..5e899b2 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "LightPivotTable", "author": "ZitRo", - "version": "1.3.0", + "version": "1.3.1", "description": "A lightweight pivot table for MDX2JSON source for InterSystems Cache", "main": "test/testServer.js", "repository": { diff --git a/readme.md b/readme.md index 650f140..4d2f6da 100644 --- a/readme.md +++ b/readme.md @@ -36,6 +36,7 @@ Then use global object constructed from LightPivotTable: var setup = { // Object that contain settings. Properties in brackets can be missed. container: document.getElementById("pivot") // HTMLElement which will contain table. [, locale: "en" ] // language to use (default: browser default or "en") + logs: false, // enable logs , dataSource: { MDX2JSONSource: "http://localhost:57772/SAMPLES", // MDX2JSON server address basicMDX: typeof req === "object" ? req.basicMDX : req @@ -54,6 +55,9 @@ var setup = { // Object that contain settings. Properties in brackets can be mis , responseHandler: function ({Object {url: {string}, status: {number}}}) {} , rowSelect: function ({Array}) {} , contentRendered: function () {} + , cellSelected: function ({ x: Number, y: Number, leftHeaderColumnsNumber: Number, topHeaderRowsNumber: Number }) { + return false; // return false to block default click action + } } ] [ , pagination: 30 ] // Maximum rows number on one page (default: 200, turn off: 0) [ , hideButtons: true ] // hides "back" and "drillThrough" buttons diff --git a/source/js/DataSource.js b/source/js/DataSource.js index 545bc2e..8afa128 100644 --- a/source/js/DataSource.js +++ b/source/js/DataSource.js @@ -226,7 +226,7 @@ DataSource.prototype.getCurrentData = function (callback) { var requestData = function () { - console.log("LPT MDX request:", mdx); + if (_.LPT.CONFIG["logs"]) console.log("LPT MDX request:", mdx); _._post( _.SOURCE_URL + "/" + diff --git a/source/js/PivotView.js b/source/js/PivotView.js index b82957b..9446ba2 100644 --- a/source/js/PivotView.js +++ b/source/js/PivotView.js @@ -54,6 +54,9 @@ var PivotView = function (controller, container) { columnIndex: 0 }; + /** + * @type {LightPivotTable} + */ this.controller = controller; this.SCROLLBAR_WIDTH = (function () { @@ -428,12 +431,22 @@ PivotView.prototype._getSelectedText = function () { PivotView.prototype._cellClickHandler = function (cell, x, y, event, drillThroughHandler) { var data = this.controller.dataController.getData(), - f = [], f1, f2, callbackRes = true, + f = [], f1, f2, callbackRes = true, result, ATTACH_TOTALS = this.controller.CONFIG["showSummary"] && this.controller.CONFIG["attachTotals"] ? 1 : 0; if (this._getSelectedText()) return; // exit if text in cell was selected + if (typeof this.controller.CONFIG.triggers["cellSelected"] === "function") { + result = this.controller.CONFIG.triggers["cellSelected"].call(this.controller, { + x: x - data.info.leftHeaderColumnsNumber, + y: y - data.info.topHeaderRowsNumber, + leftHeaderColumnsNumber: data.info.leftHeaderColumnsNumber, + topHeaderRowsNumber: data.info.topHeaderRowsNumber + }); + if (result === false) return; + } + try { f1 = data.rawData[y][data.info.leftHeaderColumnsNumber - 1].source.path; f2 = data.rawData[data.info.topHeaderRowsNumber - 1 - ATTACH_TOTALS][x].source.path;