Skip to content

Commit

Permalink
cell click handler, (fire) logs display option (default = false)
Browse files Browse the repository at this point in the history
  • Loading branch information
nikitaeverywhere committed Sep 30, 2015
1 parent df4b661 commit d020cca
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
4 changes: 4 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Then use global object constructed from <i>LightPivotTable</i>:
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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion source/js/DataSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 + "/" +
Expand Down
15 changes: 14 additions & 1 deletion source/js/PivotView.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ var PivotView = function (controller, container) {
columnIndex: 0
};

/**
* @type {LightPivotTable}
*/
this.controller = controller;

this.SCROLLBAR_WIDTH = (function () {
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit d020cca

Please sign in to comment.