1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177 | 1×
1×
1×
1×
257×
257×
257×
1×
1532×
1×
257×
1×
287×
287×
1×
338×
22×
316×
1×
34×
34×
34×
1×
33×
33×
33×
34×
34×
32×
32×
32×
1×
32×
32×
32×
32×
32×
32×
32×
30×
30×
30×
30×
1×
29×
1×
1×
1×
38×
38×
38×
38×
38×
28×
28×
1310×
1310×
30×
29×
1×
1×
1×
1×
1×
1×
1×
14×
14×
1×
1×
1×
1×
1×
1×
29×
29×
29×
29×
29×
1×
29×
29×
29×
29×
1×
51×
51×
26×
26×
25×
1×
1×
| define(["require", "exports", "../../common/base/constant", "../../common/base/constant", "../../common/popups/drillthrough-dialog", "@syncfusion/ej2-base"], function (require, exports, constant_1, events, drillthrough_dialog_1, ej2_base_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var DrillThrough = (function () {
function DrillThrough(parent) {
this.parent = parent;
this.drillThroughDialog = new drillthrough_dialog_1.DrillThroughDialog(this.parent);
this.addInternalEvents();
}
DrillThrough.prototype.getModuleName = function () {
return 'drillThrough';
};
DrillThrough.prototype.addInternalEvents = function () {
this.parent.on(constant_1.contentReady, this.wireEvents, this);
};
DrillThrough.prototype.wireEvents = function () {
this.unWireEvents();
ej2_base_1.EventHandler.add(this.parent.element, 'dblclick', this.mouseClickHandler, this);
};
DrillThrough.prototype.unWireEvents = function () {
if (this.parent.isDestroyed) {
return;
}
ej2_base_1.EventHandler.remove(this.parent.element, 'dblclick', this.mouseClickHandler);
};
DrillThrough.prototype.mouseClickHandler = function (e) {
var target = e.target;
var ele = null;
if (target.classList.contains('e-stackedheadercelldiv') || target.classList.contains('e-headercelldiv') ||
target.classList.contains('e-stackedheadertext') || target.classList.contains('e-headertext')) {
ele = ej2_base_1.closest(target.parentElement, 'th');
}
else Iif (target.classList.contains('e-cellvalue')) {
ele = target.parentElement;
}
else Eif (target.classList.contains('e-headercell') || target.classList.contains('e-rowcell')) {
ele = target;
}
Eif (ele) {
if (this.parent.pivotValues.length > 0 && (this.parent.allowDrillThrough && ele.classList.contains('e-valuescontent')
|| this.parent.editSettings.allowEditing)) {
var colIndex = Number(ele.getAttribute('data-colindex'));
var rowIndex = Number(ele.getAttribute('index'));
this.executeDrillThrough(this.parent.pivotValues[rowIndex][colIndex], rowIndex, colIndex, ele);
}
}
};
DrillThrough.prototype.executeDrillThrough = function (pivotValue, rowIndex, colIndex, element) {
this.parent.drillThroughElement = element;
this.parent.drillThroughValue = pivotValue;
var engine = this.parent.dataType === 'olap' ? this.parent.olapEngineModule : this.parent.engineModule;
var valueCaption = '';
var aggType = '';
var rawData = [];
if (!ej2_base_1.isNullOrUndefined(pivotValue.rowHeaders) && !ej2_base_1.isNullOrUndefined(pivotValue.columnHeaders)) {
Iif (this.parent.dataType === 'olap') {
var tupleInfo = void 0;
if (this.parent.dataSourceSettings.valueAxis === 'row') {
tupleInfo = engine.tupRowInfo[pivotValue.rowOrdinal];
}
else {
tupleInfo = engine.tupColumnInfo[pivotValue.colOrdinal];
}
var measureName = tupleInfo ?
engine.getUniqueName(tupleInfo.measureName) : pivotValue.actualText;
if (engine.fieldList[measureName] && engine.fieldList[measureName].isCalculatedField) {
this.parent.pivotCommon.errorDialog.createErrorDialog(this.parent.localeObj.getConstant('error'), this.parent.localeObj.getConstant('drillError'));
return;
}
valueCaption = engine.fieldList[measureName || pivotValue.actualText].caption;
aggType = engine.fieldList[measureName || pivotValue.actualText].aggregateType;
this.parent.olapEngineModule.getDrillThroughData(pivotValue, this.parent.maxRowsInDrillThrough);
try {
rawData = JSON.parse(engine.gridJSON);
}
catch (exception) {
this.parent.pivotCommon.errorDialog.createErrorDialog(this.parent.localeObj.getConstant('error'), engine.gridJSON);
return;
}
}
else {
valueCaption = engine.fieldList[pivotValue.actualText.toString()] ?
engine.fieldList[pivotValue.actualText.toString()].caption : pivotValue.actualText.toString();
aggType = engine.fieldList[pivotValue.actualText] ? engine.fieldList[pivotValue.actualText].aggregateType : '';
if (this.parent.dataSourceSettings.mode === 'Server') {
this.parent.getEngine('fetchRawData', null, null, null, null, null, null, { rowIndex: rowIndex, columnIndex: colIndex });
}
else {
if (this.parent.allowDataCompression) {
var indexArray = Object.keys(pivotValue.indexObject);
this.drillThroughDialog.indexString = [];
for (var _i = 0, indexArray_1 = indexArray; _i < indexArray_1.length; _i++) {
var cIndex = indexArray_1[_i];
for (var _a = 0, _b = this.parent.engineModule.groupRawIndex[Number(cIndex)]; _a < _b.length; _a++) {
var aIndex = _b[_a];
rawData.push(this.parent.engineModule.actualData[aIndex]);
this.drillThroughDialog.indexString.push(aIndex.toString());
}
}
}
else {
var indexArray = Object.keys(pivotValue.indexObject);
for (var _c = 0, indexArray_2 = indexArray; _c < indexArray_2.length; _c++) {
var index = indexArray_2[_c];
rawData.push(this.parent.engineModule.data[Number(index)]);
}
}
}
}
if (this.parent.dataSourceSettings.mode !== 'Server') {
this.triggerDialog(valueCaption, aggType, rawData, pivotValue, element);
}
}
};
DrillThrough.prototype.frameData = function (eventArgs) {
var keyPos = 0;
var dataPos = 0;
var data = [];
while (dataPos < eventArgs.rawData.length) {
var framedHeader = {};
while (keyPos < eventArgs.gridColumns.length) {
framedHeader[eventArgs.gridColumns[keyPos].field] = this.parent.dataSourceSettings.mode === 'Server' ?
eventArgs.rawData[dataPos][this.parent.engineModule.fields.indexOf(eventArgs.gridColumns[keyPos]
.field) !== -1 ? this.parent.engineModule.fields.indexOf(eventArgs.gridColumns[keyPos].field) : 0] :
eventArgs.rawData[dataPos][this.parent.engineModule.fieldKeys[eventArgs.gridColumns[keyPos]
.field]];
keyPos++;
}
data.push(framedHeader);
dataPos++;
keyPos = 0;
}
eventArgs.rawData = data;
return eventArgs;
};
DrillThrough.prototype.triggerDialog = function (valueCaption, aggType, rawData, pivotValue, element) {
var valuetText = aggType === 'CalculatedField' ? valueCaption.toString() : aggType !== '' ?
(this.parent.localeObj.getConstant(aggType) + ' ' + this.parent.localeObj.getConstant('of') + ' ' + valueCaption) :
valueCaption;
valuetText = this.parent.enableHtmlSanitizer ? ej2_base_1.SanitizeHtmlHelper.sanitize(valuetText) : valuetText;
var rowHeaders = this.parent.dataSourceSettings.valueAxis === 'row' ? this.parent.getRowText(Number(element.getAttribute('index')), 0) :
pivotValue.rowHeaders === '' ? '' : pivotValue.rowHeaders.toString().split(this.parent.dataSourceSettings.valueSortSettings.headerDelimiter).join(' - ');
var eventArgs = {
currentTarget: element,
currentCell: pivotValue,
rawData: rawData,
rowHeaders: rowHeaders,
columnHeaders: pivotValue.columnHeaders === '' ? '' : pivotValue.columnHeaders.toString().split(this.parent.dataSourceSettings.valueSortSettings.headerDelimiter).join(' - '),
value: valuetText + '(' + pivotValue.formattedText + ')',
gridColumns: this.drillThroughDialog.frameGridColumns(rawData),
cancel: false
};
if (this.parent.dataSourceSettings.type === 'CSV') {
eventArgs = this.frameData(eventArgs);
}
var drillThrough = this;
this.parent.trigger(events.drillThrough, eventArgs, function (observedArgs) {
Eif (!eventArgs.cancel) {
drillThrough.drillThroughDialog.showDrillThroughDialog(observedArgs);
}
});
};
DrillThrough.prototype.destroy = function () {
this.unWireEvents();
if (this.drillThroughDialog) {
this.drillThroughDialog.destroy();
this.drillThroughDialog = null;
}
else {
return;
}
};
return DrillThrough;
}());
exports.DrillThrough = DrillThrough;
});
|