@refinitiv-ui/efx-grid 6.0.104 → 6.0.106
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/core/dist/core.js +7 -8
- package/lib/core/dist/core.min.js +1 -1
- package/lib/core/es6/grid/Core.js +7 -8
- package/lib/formatters/es6/FormatterBuilder.js +10 -1
- package/lib/formatters/es6/SimpleTickerFormatter.d.ts +0 -2
- package/lib/formatters/es6/SimpleTickerFormatter.js +1 -0
- package/lib/grid/index.js +1 -1
- package/lib/rt-grid/dist/rt-grid.js +375 -737
- package/lib/rt-grid/dist/rt-grid.min.js +1 -1
- package/lib/rt-grid/es6/FieldDefinition.d.ts +2 -0
- package/lib/rt-grid/es6/FieldDefinition.js +23 -7
- package/lib/rt-grid/es6/Grid.d.ts +1 -1
- package/lib/rt-grid/es6/Grid.js +8 -49
- package/lib/rt-grid/es6/RowDefinition.d.ts +5 -3
- package/lib/rt-grid/es6/RowDefinition.js +49 -20
- package/lib/tr-grid-column-fitter/es6/ColumnFitter.js +523 -708
- package/lib/tr-grid-column-resizing/es6/ColumnResizing.d.ts +16 -16
- package/lib/tr-grid-column-resizing/es6/ColumnResizing.js +131 -109
- package/lib/tr-grid-printer/es6/CellWriter.d.ts +6 -5
- package/lib/tr-grid-printer/es6/CellWriter.js +57 -49
- package/lib/tr-grid-printer/es6/ColumnWriter.d.ts +1 -0
- package/lib/tr-grid-printer/es6/ColumnWriter.js +3 -1
- package/lib/tr-grid-printer/es6/GridPrinter.js +117 -99
- package/lib/tr-grid-printer/es6/PrintTrait.d.ts +1 -0
- package/lib/tr-grid-printer/es6/PrintTrait.js +60 -47
- package/lib/tr-grid-printer/es6/SectionWriter.d.ts +4 -1
- package/lib/tr-grid-printer/es6/SectionWriter.js +40 -15
- package/lib/tr-grid-row-grouping/es6/RowGrouping.js +6 -0
- package/lib/tr-grid-util/es6/MultiTableManager.js +1 -0
- package/lib/types/es6/ColumnResizing.d.ts +16 -16
- package/lib/types/es6/Core/data/DataCache.d.ts +0 -8
- package/lib/types/es6/RealtimeGrid/FieldDefinition.d.ts +2 -0
- package/lib/types/es6/RealtimeGrid/Grid.d.ts +1 -1
- package/lib/types/es6/RealtimeGrid/RowDefinition.d.ts +5 -3
- package/lib/versions.json +6 -6
- package/package.json +1 -1
@@ -6,7 +6,7 @@ import { Dom } from "../../tr-grid-util/es6/Dom.js";
|
|
6
6
|
* @constructor
|
7
7
|
* @extends {ElementWrapper}
|
8
8
|
*/
|
9
|
-
|
9
|
+
let CellWriter = function () {
|
10
10
|
};
|
11
11
|
Ext.inherits(CellWriter, ElementWrapper);
|
12
12
|
|
@@ -23,19 +23,34 @@ CellWriter.prototype._floatingPanel = null;
|
|
23
23
|
*/
|
24
24
|
CellWriter.prototype._frontPanel = null;
|
25
25
|
|
26
|
+
/** @private
|
27
|
+
* @type {Element}
|
28
|
+
*/
|
29
|
+
CellWriter.prototype._parent = null;
|
30
|
+
|
26
31
|
|
27
32
|
/** @public
|
28
|
-
* @return {Node
|
33
|
+
* @return {Node} content
|
34
|
+
*/
|
35
|
+
CellWriter.prototype.getParent = function () {
|
36
|
+
if(!this._parent) {
|
37
|
+
this._parent = document.createElement("div");
|
38
|
+
}
|
39
|
+
return this._parent;
|
40
|
+
};
|
41
|
+
/** @public
|
42
|
+
* @return {Node} content
|
29
43
|
*/
|
30
44
|
CellWriter.prototype.getContent = function () {
|
31
45
|
return this._elem.children[0] || null;
|
32
46
|
};
|
33
47
|
/** @public
|
34
48
|
* @param {*} content
|
35
|
-
* @param {boolean=}
|
49
|
+
* @param {boolean=} tooltip
|
36
50
|
* @return {Element}
|
37
51
|
*/
|
38
|
-
CellWriter.prototype.setContent = function (content,
|
52
|
+
CellWriter.prototype.setContent = function (content, tooltip) {
|
53
|
+
Dom.removeChildren(this._elem);
|
39
54
|
if(content == null) {
|
40
55
|
return null;
|
41
56
|
}
|
@@ -44,7 +59,7 @@ CellWriter.prototype.setContent = function (content, opt_tooltip) {
|
|
44
59
|
} else if(content.nodeType !== 1) {
|
45
60
|
content = this._createTextContent(content);
|
46
61
|
}
|
47
|
-
|
62
|
+
|
48
63
|
this._elem.appendChild(/** @type{Node} */(content));
|
49
64
|
return /** @type{Element} */(content);
|
50
65
|
};
|
@@ -82,7 +97,7 @@ CellWriter.prototype.addContent = function (n) {
|
|
82
97
|
* @return {Element}
|
83
98
|
*/
|
84
99
|
CellWriter.prototype._createTextContent = function (str) {
|
85
|
-
|
100
|
+
let div = Dom.div("text");
|
86
101
|
if(str != null) {
|
87
102
|
div.textContent = str;
|
88
103
|
this["percentText"] = str; // HACK
|
@@ -97,6 +112,26 @@ CellWriter.prototype._createTextContent = function (str) {
|
|
97
112
|
CellWriter.prototype.setStyle = function (str, val) {
|
98
113
|
this._elem.style[str] = val;
|
99
114
|
};
|
115
|
+
/** @private
|
116
|
+
* @returns {!Element} flex row
|
117
|
+
*/
|
118
|
+
CellWriter.prototype._insertFlexRow = function () {
|
119
|
+
let flexRow = this._flexRow;
|
120
|
+
if(!flexRow) {
|
121
|
+
flexRow = this._flexRow = document.createElement("div");
|
122
|
+
flexRow.className = "tr-printing-flex-row";
|
123
|
+
}
|
124
|
+
|
125
|
+
let elem = this._elem;
|
126
|
+
if(elem.firstChild !== flexRow) {
|
127
|
+
while(elem.firstChild) {
|
128
|
+
flexRow.appendChild(elem.firstChild);
|
129
|
+
}
|
130
|
+
elem.appendChild(flexRow);
|
131
|
+
}
|
132
|
+
|
133
|
+
return flexRow;
|
134
|
+
};
|
100
135
|
/** @public
|
101
136
|
* @param {*} n
|
102
137
|
*/
|
@@ -106,26 +141,14 @@ CellWriter.prototype.removeIcon = function (n) {};
|
|
106
141
|
*/
|
107
142
|
CellWriter.prototype.updateIcon = function (elem) {
|
108
143
|
if(elem && elem.nodeType === 1) {
|
109
|
-
|
144
|
+
let flexRow = this._insertFlexRow();
|
145
|
+
let fp = this._frontPanel;
|
110
146
|
if(!fp) {
|
111
|
-
this.
|
112
|
-
|
113
|
-
|
114
|
-
fp = this._floatingPanel = document.createElement("div");
|
115
|
-
fp.className = "tr-printing-float-right";
|
116
|
-
this._flexRow.appendChild(fp);
|
117
|
-
var chdr = this._elem.children;
|
118
|
-
var childCount = chdr.length;
|
119
|
-
if(childCount) {
|
120
|
-
var ary = new Array(childCount);
|
121
|
-
for(var i = 0; i < childCount; ++i) {
|
122
|
-
ary[i] = chdr[i];
|
123
|
-
}
|
124
|
-
Dom.appendChild(this._flexRow, ary);
|
125
|
-
}
|
126
|
-
this._elem.appendChild(this._flexRow);
|
147
|
+
fp = this._frontPanel = document.createElement("div");
|
148
|
+
fp.className = "tr-printing-float-right"; // WARNING: This may need to be float-left
|
149
|
+
flexRow.insertBefore(fp, flexRow.firstChild);
|
127
150
|
}
|
128
|
-
fp.appendChild(elem.cloneNode(true));
|
151
|
+
fp.appendChild(elem.cloneNode(true)); // WARNING: This may not need to be cloned
|
129
152
|
}
|
130
153
|
};
|
131
154
|
/** @public
|
@@ -135,10 +158,6 @@ CellWriter.prototype.unlisten = function () {};
|
|
135
158
|
*/
|
136
159
|
CellWriter.prototype.listen = function () {};
|
137
160
|
|
138
|
-
/** @public
|
139
|
-
*/
|
140
|
-
CellWriter.prototype.setTooltip = function () {};
|
141
|
-
|
142
161
|
/** @public
|
143
162
|
* @param {string} str
|
144
163
|
*/
|
@@ -147,9 +166,10 @@ CellWriter.prototype.addClass = function (str) {
|
|
147
166
|
};
|
148
167
|
/** @public
|
149
168
|
* @param {string} str
|
169
|
+
* @returns {boolean}
|
150
170
|
*/
|
151
171
|
CellWriter.prototype.hasClass = function (str) {
|
152
|
-
this._elem.classList.contains(str);
|
172
|
+
return this._elem.classList.contains(str);
|
153
173
|
};
|
154
174
|
/** @public
|
155
175
|
* @param {string} str
|
@@ -175,26 +195,14 @@ CellWriter.prototype.enableClass = function (str, bool) {
|
|
175
195
|
*/
|
176
196
|
CellWriter.prototype.insertFloatingIcon = function (elem, order) {
|
177
197
|
if(elem && elem.nodeType === 1) {
|
178
|
-
|
198
|
+
let flexRow = this._insertFlexRow();
|
199
|
+
let fp = this._floatingPanel;
|
179
200
|
if(!fp) {
|
180
|
-
this._flexRow = document.createElement("div");
|
181
|
-
this._flexRow.className = "tr-printing-flex-row";
|
182
|
-
|
183
|
-
var chdr = this._elem.children;
|
184
|
-
var childCount = chdr.length;
|
185
|
-
if(childCount) {
|
186
|
-
var ary = new Array(childCount);
|
187
|
-
for(var i = 0; i < childCount; ++i) {
|
188
|
-
ary[i] = chdr[i];
|
189
|
-
}
|
190
|
-
Dom.appendChild(this._flexRow, ary);
|
191
|
-
}
|
192
201
|
fp = this._floatingPanel = document.createElement("div");
|
193
202
|
fp.className = "tr-printing-float-right";
|
194
|
-
|
195
|
-
this._elem.appendChild(this._flexRow);
|
203
|
+
flexRow.appendChild(fp);
|
196
204
|
}
|
197
|
-
fp.appendChild(elem.cloneNode(true));
|
205
|
+
fp.appendChild(elem.cloneNode(true)); // WARNING: This may not need to be cloned
|
198
206
|
}
|
199
207
|
};
|
200
208
|
/** @public
|
@@ -214,13 +222,13 @@ CellWriter.prototype.getSection = function () {
|
|
214
222
|
* @param {Element} elem
|
215
223
|
*/
|
216
224
|
CellWriter.prototype.cloak = function (elem) {
|
217
|
-
|
218
|
-
|
219
|
-
delete this._floatingPanel;
|
220
|
-
delete this._frontPanel;
|
225
|
+
this.percentText = ""; // Hack
|
226
|
+
this._flexRow = this._frontPanel = this._floatingPanel = null;
|
221
227
|
elem.className = "cell";
|
222
228
|
this._elem = elem;
|
223
229
|
};
|
224
230
|
|
225
231
|
|
232
|
+
|
233
|
+
export default CellWriter;
|
226
234
|
export { CellWriter };
|
@@ -5,7 +5,7 @@ import { ElementWrapper } from "../../tr-grid-util/es6/ElementWrapper.js";
|
|
5
5
|
* @constructor
|
6
6
|
* @extends {ElementWrapper}
|
7
7
|
*/
|
8
|
-
|
8
|
+
let ColumnWriter = function () {
|
9
9
|
};
|
10
10
|
Ext.inherits(ColumnWriter, ElementWrapper);
|
11
11
|
|
@@ -18,4 +18,6 @@ ColumnWriter.prototype.isActive = function () {
|
|
18
18
|
};
|
19
19
|
|
20
20
|
|
21
|
+
|
22
|
+
export default ColumnWriter;
|
21
23
|
export { ColumnWriter };
|
@@ -9,7 +9,7 @@ import { SectionWriter } from "./SectionWriter.js";
|
|
9
9
|
/** @private
|
10
10
|
* @type {Node}
|
11
11
|
*/
|
12
|
-
|
12
|
+
let _dummyNode = null;
|
13
13
|
|
14
14
|
|
15
15
|
/** TODO: Move this logic to PrintTrait
|
@@ -17,9 +17,9 @@ var _dummyNode = null;
|
|
17
17
|
* @param {Object=} options
|
18
18
|
* @return {!Object}
|
19
19
|
*/
|
20
|
-
|
21
|
-
|
22
|
-
|
20
|
+
let _getPageSize = function (options) {
|
21
|
+
let pageWidth = 0;
|
22
|
+
let pageHeight = 0;
|
23
23
|
|
24
24
|
if (options) {
|
25
25
|
if (options["pageWidth"]) {
|
@@ -50,7 +50,7 @@ var _getPageSize = function (options) {
|
|
50
50
|
* @param {Node} nodeA
|
51
51
|
* @param {Node} nodeB
|
52
52
|
*/
|
53
|
-
|
53
|
+
let swapNode = function (nodeA, nodeB) {
|
54
54
|
if (!nodeA || !nodeB || !nodeA.parentNode || !nodeB.parentNode) {
|
55
55
|
Dom.removeParent(nodeA);
|
56
56
|
Dom.removeParent(nodeB);
|
@@ -69,9 +69,9 @@ var swapNode = function (nodeA, nodeB) {
|
|
69
69
|
* @param {Node} fromNode
|
70
70
|
* @param {Node} toNode
|
71
71
|
*/
|
72
|
-
|
72
|
+
let copyNode = function (fromNode, toNode) {
|
73
73
|
if (fromNode && toNode) {
|
74
|
-
|
74
|
+
let i, attrs;
|
75
75
|
if (toNode.hasAttributes()) {
|
76
76
|
attrs = toNode.attributes;
|
77
77
|
for (i = attrs.length; --i >= 0;) {
|
@@ -88,8 +88,8 @@ var copyNode = function (fromNode, toNode) {
|
|
88
88
|
|
89
89
|
Dom.removeChildren(toNode);
|
90
90
|
|
91
|
-
|
92
|
-
|
91
|
+
let chdr = fromNode.childNodes;
|
92
|
+
let childCount = chdr.length;
|
93
93
|
for (i = 0; i < childCount; ++i) {
|
94
94
|
toNode.appendChild(chdr[i].cloneNode(true));
|
95
95
|
}
|
@@ -101,14 +101,14 @@ var copyNode = function (fromNode, toNode) {
|
|
101
101
|
* @param {number} colIndex
|
102
102
|
* @param {string} alignment
|
103
103
|
*/
|
104
|
-
|
104
|
+
let _setColumnAlignment = function (tbl, colIndex, alignment) {
|
105
105
|
if (!alignment || alignment === "default") {
|
106
106
|
return;
|
107
107
|
}
|
108
|
-
|
108
|
+
let cells = tbl.getCellsInColumn(colIndex);
|
109
109
|
if (!cells) return;
|
110
|
-
for (
|
111
|
-
|
110
|
+
for (let i = cells.length; --i >= 0;) {
|
111
|
+
let cell = cells[i];
|
112
112
|
cell.classList.add("tr-align-" + alignment);
|
113
113
|
}
|
114
114
|
};
|
@@ -117,8 +117,8 @@ var _setColumnAlignment = function (tbl, colIndex, alignment) {
|
|
117
117
|
* @param {*} grid grid element, currently supports atlas-blotter, ef-grid, tr.CompositeGrid, rt.Grid and Core
|
118
118
|
* @return {Object} core grid
|
119
119
|
*/
|
120
|
-
|
121
|
-
|
120
|
+
let _getCoreGrid = function (grid) {
|
121
|
+
let core = null;
|
122
122
|
try {
|
123
123
|
if (grid.api) { // ef-grid or atlas-blotter
|
124
124
|
core = grid.api.getCoreGrid();
|
@@ -136,7 +136,7 @@ var _getCoreGrid = function (grid) {
|
|
136
136
|
|
137
137
|
/** @namespace
|
138
138
|
*/
|
139
|
-
|
139
|
+
let GridPrinter = {};
|
140
140
|
/** @private
|
141
141
|
* @type {string}
|
142
142
|
*/
|
@@ -156,7 +156,7 @@ GridPrinter._grid = null;
|
|
156
156
|
/** @type {boolean}
|
157
157
|
* @private
|
158
158
|
*/
|
159
|
-
GridPrinter.
|
159
|
+
GridPrinter._manualObs = false;
|
160
160
|
/** @type {!Object}
|
161
161
|
* @private
|
162
162
|
*/
|
@@ -177,14 +177,16 @@ GridPrinter.setPrintOptions = function (options) {
|
|
177
177
|
* @param {HTMLIFrameElement=} iFrameElement If not specified, current window is used instead. Specify null to un-observe existing window object.
|
178
178
|
*/
|
179
179
|
GridPrinter.observe = function (iFrameElement) {
|
180
|
-
|
180
|
+
let pt = GridPrinter.getPrintTrait();
|
181
181
|
pt.observe(iFrameElement);
|
182
|
-
GridPrinter.
|
182
|
+
GridPrinter._manualObs = pt.isObserving();
|
183
183
|
};
|
184
184
|
/** @public
|
185
185
|
*/
|
186
186
|
GridPrinter.unobserve = function () {
|
187
|
-
GridPrinter.
|
187
|
+
let pt = GridPrinter.getPrintTrait();
|
188
|
+
pt.unobserve();
|
189
|
+
GridPrinter._manualObs = pt.isObserving();
|
188
190
|
};
|
189
191
|
/** @public
|
190
192
|
* @param {boolean=} bool
|
@@ -199,7 +201,7 @@ GridPrinter.enableDebugMode = function (bool) {
|
|
199
201
|
* @return {!Object}
|
200
202
|
*/
|
201
203
|
GridPrinter.getPreFlightInfo = function (grid, options) {
|
202
|
-
|
204
|
+
let pfInfo = options || {};
|
203
205
|
if (!pfInfo.pageCount) {
|
204
206
|
pfInfo.pageCount = 0;
|
205
207
|
}
|
@@ -207,7 +209,7 @@ GridPrinter.getPreFlightInfo = function (grid, options) {
|
|
207
209
|
return pfInfo;
|
208
210
|
}
|
209
211
|
|
210
|
-
|
212
|
+
let colCount = grid.getColumnCount();
|
211
213
|
if (!colCount) {
|
212
214
|
return pfInfo;
|
213
215
|
}
|
@@ -219,14 +221,14 @@ GridPrinter.getPreFlightInfo = function (grid, options) {
|
|
219
221
|
options.pageHeight = GridPrinter._options["pageHeight"];
|
220
222
|
}
|
221
223
|
|
222
|
-
|
223
|
-
|
224
|
-
|
224
|
+
let pageSize = _getPageSize(options);
|
225
|
+
let pageWidth = pfInfo.pageWidth = pageSize.pageWidth;
|
226
|
+
let pageHeight = pfInfo.pageHeight = pageSize.pageHeight;
|
225
227
|
|
226
228
|
// Find primary column that will exist in every page
|
227
|
-
|
228
|
-
|
229
|
-
|
229
|
+
let c;
|
230
|
+
let primaryColIndex = 0;
|
231
|
+
let identifierCol = GridPrinter._options["identifierField"] || GridPrinter._options["primaryColumn"];
|
230
232
|
// if(typeof identifierCol === "string") {
|
231
233
|
// for(c = 0; c < colCount; ++c) {
|
232
234
|
// if() {
|
@@ -237,21 +239,21 @@ GridPrinter.getPreFlightInfo = function (grid, options) {
|
|
237
239
|
primaryColIndex = identifierCol;
|
238
240
|
}
|
239
241
|
|
240
|
-
|
242
|
+
let primaryCol = pfInfo.primaryColumn = GridPrinter._newColInfo(grid, primaryColIndex);
|
241
243
|
|
242
244
|
// Collect properties from all visible columns
|
243
245
|
// Create a column set that fit the page width
|
244
246
|
// Create multiple column sets for single grid
|
245
|
-
|
246
|
-
|
247
|
-
//
|
248
|
-
|
247
|
+
let colSets = []; // Each set will fit a single page
|
248
|
+
let colSet, colInfo;
|
249
|
+
// let defaultMinWidth = 50; // WARNING: Hardcoded value
|
250
|
+
let availSpace = 0;
|
249
251
|
for (c = 0; c < colCount; ++c) {
|
250
252
|
if (c == primaryCol.index) {
|
251
253
|
continue;
|
252
254
|
}
|
253
255
|
|
254
|
-
|
256
|
+
let colVisible = grid.isColumnVisible(c);
|
255
257
|
if (!colVisible) {
|
256
258
|
continue;
|
257
259
|
}
|
@@ -272,7 +274,7 @@ GridPrinter.getPreFlightInfo = function (grid, options) {
|
|
272
274
|
}
|
273
275
|
|
274
276
|
|
275
|
-
|
277
|
+
let colSetCount = colSets.length;
|
276
278
|
if (!colSetCount) {
|
277
279
|
colSetCount = 1;
|
278
280
|
colSets.push([primaryCol]);
|
@@ -280,10 +282,10 @@ GridPrinter.getPreFlightInfo = function (grid, options) {
|
|
280
282
|
pfInfo.columnSets = colSets;
|
281
283
|
|
282
284
|
// Resolve scalable columns and width
|
283
|
-
for (
|
285
|
+
for (let i = 0; i < colSetCount; ++i) {
|
284
286
|
colSet = colSets[i];
|
285
287
|
colCount = colSet.columns.length;
|
286
|
-
|
288
|
+
let scalableColumns = [];
|
287
289
|
availSpace = pageWidth;
|
288
290
|
for (c = 0; c < colCount; ++c) {
|
289
291
|
colInfo = colSet.columns[c];
|
@@ -293,16 +295,16 @@ GridPrinter.getPreFlightInfo = function (grid, options) {
|
|
293
295
|
availSpace -= colInfo.width;
|
294
296
|
}
|
295
297
|
}
|
296
|
-
|
298
|
+
let scalableColCount = scalableColumns.length;
|
297
299
|
if (scalableColCount) {
|
298
|
-
|
300
|
+
let avgWidth = (availSpace / scalableColCount); // TODO: Take min width into account
|
299
301
|
for (c = 0; c < scalableColCount; ++c) {
|
300
302
|
scalableColumns[c].width = (avgWidth * (c + 1) | 0) - (avgWidth * c | 0);
|
301
303
|
}
|
302
304
|
}
|
303
305
|
|
304
|
-
|
305
|
-
|
306
|
+
let totalWidth = 0;
|
307
|
+
let widths = colSet.widths = new Array(colCount);
|
306
308
|
for (c = 0; c < colCount; ++c) {
|
307
309
|
colInfo = colSet.columns[c];
|
308
310
|
widths[c] = colInfo.width;
|
@@ -312,21 +314,21 @@ GridPrinter.getPreFlightInfo = function (grid, options) {
|
|
312
314
|
}
|
313
315
|
|
314
316
|
// Find total row count per table. Remove all empty rows after the last occupied row.
|
315
|
-
|
316
|
-
|
317
|
+
let dv = grid.getDataSource();
|
318
|
+
let totalRowCount = pfInfo.totalRowcount = dv.getVisibleRowCount();
|
317
319
|
|
318
320
|
// Find cutoff point for each page
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
321
|
+
let titleSect = grid.getSection("title");
|
322
|
+
let headerHeight = pfInfo.headerHeight = (titleSect.isVisible()) ? titleSect.getDefaultRowHeight() : 0;
|
323
|
+
let rowHeight = pfInfo.rowHeight = grid.getSection("content").getDefaultRowHeight();
|
324
|
+
let maxRowPerPage = (pageHeight - headerHeight) / rowHeight | 0;
|
323
325
|
if (!(maxRowPerPage > 0)) { // NaN, negative number, or zero is not allowed.
|
324
326
|
maxRowPerPage = 1; // number of content rows
|
325
327
|
}
|
326
328
|
pfInfo.maxRowPerPage = maxRowPerPage;
|
327
329
|
|
328
|
-
|
329
|
-
//
|
330
|
+
let gridCount = pfInfo.gridCount = Math.ceil(totalRowCount / maxRowPerPage); // Number of grid require to render all of the rows. Grid must fit a single page
|
331
|
+
// let lastPageRowCount = totalRowCount - (totalRowCount / maxRowPerPage | 0);
|
330
332
|
pfInfo.pageCount = gridCount * colSetCount;
|
331
333
|
|
332
334
|
|
@@ -334,10 +336,10 @@ GridPrinter.getPreFlightInfo = function (grid, options) {
|
|
334
336
|
// if(colSetCount == 1 && pageCount > 1) {
|
335
337
|
// availSpace = pageWidth;
|
336
338
|
// tableWidth = tables[0]._width;
|
337
|
-
//
|
339
|
+
// let numGridPerPage = Math.floor(pageWidth / tableWidth);
|
338
340
|
|
339
|
-
//
|
340
|
-
//
|
341
|
+
// let margin = 4;
|
342
|
+
// let takenSpace = numTablePerPage * tableWidth + (numTablePerPage - 1) * margin;
|
341
343
|
// if(takenSpace > pageWidth) {
|
342
344
|
// numGridPerPage--; // There is not enough space for margin
|
343
345
|
// }
|
@@ -367,46 +369,47 @@ GridPrinter.createPrintElement = function (grid, options) {
|
|
367
369
|
return null;
|
368
370
|
}
|
369
371
|
|
370
|
-
|
372
|
+
let pfInfo = options || GridPrinter._printInfo;
|
371
373
|
if (!pfInfo || !pfInfo._calculated) {
|
372
374
|
pfInfo = GridPrinter.getPreFlightInfo(grid, pfInfo);
|
373
375
|
}
|
374
376
|
|
375
377
|
// TODO: Check if we need to recalculate everything again
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
378
|
+
let maxRowPerPage = pfInfo.maxRowPerPage;
|
379
|
+
let totalRowCount = pfInfo.totalRowcount;
|
380
|
+
let rowHeight = pfInfo.rowHeight;
|
381
|
+
let headerHeight = pfInfo.headerHeight;
|
382
|
+
let colSets = pfInfo.columnSets;
|
383
|
+
let colSetCount = pfInfo.columnSets.length;
|
384
|
+
let primaryColumn = pfInfo.primaryColumn;
|
385
|
+
let gridCount = pfInfo.gridCount;
|
386
|
+
let contentWriter = new SectionWriter(); // content section
|
387
|
+
let headerWriter = new SectionWriter();
|
388
|
+
|
389
|
+
let gridContentSection = grid.getSectionSettings("content");
|
388
390
|
gridContentSection.snapshot(contentWriter);
|
389
391
|
|
390
|
-
|
392
|
+
let gridHeaderSection = grid.getSectionSettings("title");
|
391
393
|
if (gridHeaderSection) {
|
392
394
|
gridHeaderSection.snapshot(headerWriter);
|
393
395
|
}
|
394
396
|
|
395
397
|
// Begin element construction
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
398
|
+
let tables = [];
|
399
|
+
let t;
|
400
|
+
for (t = 0; t < gridCount; ++t) { // For each table
|
401
|
+
let rowStart = t * maxRowPerPage;
|
402
|
+
let rowEnd = rowStart + maxRowPerPage;
|
400
403
|
if (rowEnd > totalRowCount) {
|
401
404
|
rowEnd = totalRowCount;
|
402
405
|
}
|
403
|
-
|
406
|
+
let rowCount = rowEnd - rowStart;
|
404
407
|
|
405
|
-
for (
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
408
|
+
for (let s = 0; s < colSetCount; ++s) { // For each column set
|
409
|
+
let colSet = colSets[s];
|
410
|
+
let colCount = colSet.columns.length;
|
411
|
+
let c, col, colIndex;
|
412
|
+
let tbl = new Table(null, {
|
410
413
|
colCount: colCount,
|
411
414
|
rowCount: rowCount,
|
412
415
|
rowHeight: rowHeight
|
@@ -416,7 +419,7 @@ GridPrinter.createPrintElement = function (grid, options) {
|
|
416
419
|
|
417
420
|
if (headerHeight) {
|
418
421
|
tbl.addHeaderRows(); // TODO: support multiple rows
|
419
|
-
|
422
|
+
let thead = tbl.getHeader();
|
420
423
|
thead.setDefaultRowHeight(headerHeight);
|
421
424
|
|
422
425
|
// Render header columns
|
@@ -434,12 +437,12 @@ GridPrinter.createPrintElement = function (grid, options) {
|
|
434
437
|
for (c = 0; c < colCount; ++c) { // Populate each cell
|
435
438
|
col = colSet.columns[c];
|
436
439
|
colIndex = col.index;
|
437
|
-
|
440
|
+
let isPrimary = colIndex === primaryColumn.index;
|
438
441
|
|
439
|
-
for (
|
440
|
-
|
441
|
-
|
442
|
-
|
442
|
+
for (let r = 0; r < rowCount; ++r) {
|
443
|
+
let rowIndex = rowStart + r;
|
444
|
+
let masterCell = contentWriter.getCellElement(colIndex, rowIndex);
|
445
|
+
let cell = tbl.getCell(c, r);
|
443
446
|
if (isPrimary) {
|
444
447
|
copyNode(masterCell, cell);
|
445
448
|
} else {
|
@@ -456,8 +459,8 @@ GridPrinter.createPrintElement = function (grid, options) {
|
|
456
459
|
}
|
457
460
|
|
458
461
|
// Produce the root element to be appended to the page
|
459
|
-
|
460
|
-
|
462
|
+
let pageCount = pfInfo.pageCount;
|
463
|
+
let rootElem = document.createElement("div");
|
461
464
|
rootElem.className = "tr-printing-root";
|
462
465
|
rootElem.style.display = "block"; // This will beat any CSS selector
|
463
466
|
for (t = 0; t < pageCount; ++t) {
|
@@ -650,7 +653,7 @@ GridPrinter._applyCss = function () {
|
|
650
653
|
* @param {*} grid grid element, currently supports efx-grid, atlas-blotter, ef-grid, tr.CompositeGrid, rt.Grid and Core
|
651
654
|
*/
|
652
655
|
GridPrinter.print = function (grid) {
|
653
|
-
|
656
|
+
let core = null;
|
654
657
|
if (grid) {
|
655
658
|
GridPrinter._applyCss();
|
656
659
|
core = _getCoreGrid(grid);
|
@@ -659,8 +662,8 @@ GridPrinter.print = function (grid) {
|
|
659
662
|
if (core) {
|
660
663
|
GridPrinter._grid = core;
|
661
664
|
|
662
|
-
|
663
|
-
if (!GridPrinter.
|
665
|
+
let pt = GridPrinter.getPrintTrait(); // initialize
|
666
|
+
if (!GridPrinter._manualObs) {
|
664
667
|
pt.observe(); // Observe current window
|
665
668
|
}
|
666
669
|
|
@@ -671,20 +674,35 @@ GridPrinter.print = function (grid) {
|
|
671
674
|
};
|
672
675
|
|
673
676
|
|
674
|
-
/** @
|
677
|
+
/** @public
|
678
|
+
* @ignore
|
675
679
|
* @return {!PrintTrait}
|
676
680
|
*/
|
677
|
-
GridPrinter.
|
678
|
-
|
681
|
+
GridPrinter.getPrintTrait = function () {
|
682
|
+
let pt = GridPrinter._printTrait;
|
679
683
|
if (!pt) {
|
680
|
-
pt =
|
681
|
-
|
684
|
+
pt = new PrintTrait();
|
685
|
+
GridPrinter.setPrintTrait(pt);
|
686
|
+
}
|
687
|
+
return pt;
|
688
|
+
};
|
689
|
+
/** @public
|
690
|
+
* @ignore
|
691
|
+
* @param {PrintTrait} pt
|
692
|
+
*/
|
693
|
+
GridPrinter.setPrintTrait = function (pt) {
|
694
|
+
if(GridPrinter._printTrait && GridPrinter._printTrait !== pt) {
|
695
|
+
GridPrinter._printTrait.dispose();
|
696
|
+
}
|
697
|
+
|
698
|
+
GridPrinter._printTrait = pt || null;
|
699
|
+
if (pt) {
|
700
|
+
// TODO: pt.fixPaperSize(); // WORKAROUND: We cannot detect the change in paper size during the browser's preview dialog.
|
682
701
|
|
683
702
|
pt.addEventListener('pageCounting', GridPrinter._onPageCounting);
|
684
703
|
pt.addEventListener('beforeprint', GridPrinter._onBeforePrint);
|
685
704
|
pt.addEventListener('afterprint', GridPrinter._onAfterPrint);
|
686
705
|
}
|
687
|
-
return pt;
|
688
706
|
};
|
689
707
|
/** @private
|
690
708
|
* @param {tr.Grid} grid
|
@@ -692,12 +710,12 @@ GridPrinter._getPrintTrait = function () {
|
|
692
710
|
* @return {!Object}
|
693
711
|
*/
|
694
712
|
GridPrinter._newColInfo = function (grid, idx) {
|
695
|
-
|
713
|
+
let minWidth = grid.getMinimumColumnWidth(idx);
|
696
714
|
if (minWidth <= 0) {
|
697
715
|
minWidth = 50; // WARNING: Hard-coded value
|
698
716
|
}
|
699
|
-
|
700
|
-
|
717
|
+
let scalability = grid.getColumnScalability(idx);
|
718
|
+
let width = scalability ? minWidth : grid.getColumnWidth(idx);
|
701
719
|
|
702
720
|
return {
|
703
721
|
"index": idx,
|
@@ -741,7 +759,7 @@ GridPrinter._onBeforePrint = function (e) {
|
|
741
759
|
if (GridPrinter._printInfo && GridPrinter._printInfo.pageCount) {
|
742
760
|
GridPrinter._printElem = GridPrinter.createPrintElement(GridPrinter._grid, GridPrinter._printInfo); // TODO: Use new sizes given from PrintTrait
|
743
761
|
|
744
|
-
//
|
762
|
+
// let elem = GridPrinter._printTrait.createClientBox(e.pageWidth, e.pageHeight);
|
745
763
|
e.bodyElement.appendChild(GridPrinter._printElem);
|
746
764
|
}
|
747
765
|
};
|
@@ -751,8 +769,8 @@ GridPrinter._onBeforePrint = function (e) {
|
|
751
769
|
GridPrinter._onAfterPrint = function (e) {
|
752
770
|
GridPrinter._removePrintElements();
|
753
771
|
|
754
|
-
if (!GridPrinter.
|
755
|
-
GridPrinter.
|
772
|
+
if (!GridPrinter._manualObs) {
|
773
|
+
GridPrinter.getPrintTrait().unobserve();
|
756
774
|
}
|
757
775
|
|
758
776
|
GridPrinter._printInfo = null;
|