@refinitiv-ui/efx-grid 6.0.93 → 6.0.94
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/formatters/es6/CoralButtonFormatter.d.ts +0 -2
- package/lib/formatters/es6/CoralButtonFormatter.js +9 -4
- package/lib/formatters/es6/CoralCheckboxFormatter.js +10 -5
- package/lib/formatters/es6/CoralComboBoxFormatter.js +13 -12
- package/lib/formatters/es6/CoralIconFormatter.d.ts +0 -2
- package/lib/formatters/es6/CoralIconFormatter.js +9 -4
- package/lib/formatters/es6/CoralInputFormatter.js +9 -4
- package/lib/formatters/es6/CoralRadioButtonFormatter.d.ts +0 -2
- package/lib/formatters/es6/CoralRadioButtonFormatter.js +20 -15
- package/lib/formatters/es6/CoralSelectFormatter.js +12 -7
- package/lib/formatters/es6/CoralToggleFormatter.js +4 -4
- package/lib/formatters/es6/DuplexEmeraldDateTimePickerFormatter.js +20 -20
- package/lib/formatters/es6/EFButtonFormatter.d.ts +0 -2
- package/lib/formatters/es6/EFButtonFormatter.js +9 -4
- package/lib/formatters/es6/EFCheckboxFormatter.js +10 -5
- package/lib/formatters/es6/EFComboBoxFormatter.js +17 -7
- package/lib/formatters/es6/EFDateTimePickerFormatter.js +11 -6
- package/lib/formatters/es6/EFIconFormatter.d.ts +0 -2
- package/lib/formatters/es6/EFIconFormatter.js +9 -4
- package/lib/formatters/es6/EFNumberFieldFormatter.js +9 -4
- package/lib/formatters/es6/EFRadioButtonFormatter.d.ts +0 -2
- package/lib/formatters/es6/EFRadioButtonFormatter.js +25 -15
- package/lib/formatters/es6/EFSelectFormatter.js +17 -7
- package/lib/formatters/es6/EFTextFieldFormatter.js +4 -4
- package/lib/formatters/es6/EFToggleFormatter.js +4 -4
- package/lib/formatters/es6/EmeraldDateTimePickerFormatter.js +6 -6
- package/lib/formatters/es6/FormatterBuilder.js +32 -32
- package/lib/formatters/es6/NumericInputFormatter.js +7 -7
- package/lib/formatters/es6/PercentBarFormatter.js +5 -5
- package/lib/formatters/es6/SimpleImageFormatter.js +3 -3
- package/lib/formatters/es6/SimpleInputFormatter.js +4 -4
- package/lib/formatters/es6/SimpleLinkFormatter.js +4 -4
- package/lib/formatters/es6/SimpleTickerFormatter.js +5 -5
- package/lib/formatters/es6/SimpleToggleFormatter.js +16 -16
- package/lib/formatters/es6/TextFormatter.js +4 -4
- package/lib/grid/index.js +1 -1
- package/lib/tr-grid-cell-selection/es6/CellSelection.js +1 -1
- package/lib/tr-grid-row-dragging/es6/RowDragging.js +1 -1
- package/lib/tr-grid-row-grouping/es6/RowGrouping.js +139 -137
- package/lib/tr-grid-row-selection/es6/RowSelection.js +260 -279
- package/lib/tr-grid-util/es6/DragUI.js +1 -1
- package/lib/types/es6/ColumnGrouping.d.ts +1 -2
- package/lib/versions.json +6 -6
- package/package.json +1 -1
@@ -4,7 +4,13 @@ import { GridPlugin } from "../../tr-grid-util/es6/GridPlugin.js";
|
|
4
4
|
import { isMac as isMacFn } from "../../tr-grid-util/es6/Util.js";
|
5
5
|
import { isIE, prepareTSVContent } from "../../tr-grid-util/es6/Util.js";
|
6
6
|
import { prettifyCss } from "../../tr-grid-util/es6/Util.js";
|
7
|
-
|
7
|
+
|
8
|
+
/** @private
|
9
|
+
* @type {boolean}
|
10
|
+
* @constant
|
11
|
+
*/
|
12
|
+
const IS_MAC = isMacFn();
|
13
|
+
|
8
14
|
/** Fired when selection is changed by mouse down or key press. A change by JavaScript APIs will not trigger this event.
|
9
15
|
* @event RowSelectionPlugin#selectionChanged
|
10
16
|
*/
|
@@ -13,7 +19,7 @@ var isMac = isMacFn();
|
|
13
19
|
* Note that selection by JavaScript APIs cannot be prevented using this event.
|
14
20
|
* @event RowSelectionPlugin#beforeSelection
|
15
21
|
* @example
|
16
|
-
*
|
22
|
+
* let ext = new RowSelectionPlugin();
|
17
23
|
* ext.listen("beforeSelection" function(e) {
|
18
24
|
* e.cancel = true; // Cancel user selection
|
19
25
|
* });
|
@@ -34,11 +40,10 @@ var isMac = isMacFn();
|
|
34
40
|
* @extends {GridPlugin}
|
35
41
|
* @param {RowSelectionPlugin~Options=} options
|
36
42
|
*/
|
37
|
-
|
38
|
-
|
43
|
+
let RowSelectionPlugin = function (options) {
|
44
|
+
let t = this;
|
39
45
|
t._onMouseDown = t._onMouseDown.bind(t);
|
40
46
|
t._onMouseMove = t._onMouseMove.bind(t);
|
41
|
-
t._onCopy = t._onCopy.bind(t);
|
42
47
|
t._onClick = t._onClick.bind(t);
|
43
48
|
t._onKeyDown = t._onKeyDown.bind(t);
|
44
49
|
t._onBeforeRowRemoved = t._onBeforeRowRemoved.bind(t);
|
@@ -51,7 +56,7 @@ var RowSelectionPlugin = function (options) {
|
|
51
56
|
t._isIE = isIE();
|
52
57
|
t._textRange = document.createRange();
|
53
58
|
|
54
|
-
if
|
59
|
+
if(options) {
|
55
60
|
t.config({ "rowSelection": options });
|
56
61
|
}
|
57
62
|
};
|
@@ -133,7 +138,7 @@ RowSelectionPlugin.prototype._pendingSelection = null;
|
|
133
138
|
* @return {string}
|
134
139
|
*/
|
135
140
|
RowSelectionPlugin._styleCalculator = function() {
|
136
|
-
|
141
|
+
let styles = [
|
137
142
|
".row-selection-menu", [
|
138
143
|
"position: absolute;",
|
139
144
|
"background-color: var(--grid-column-menu-icon-bgcolor);",
|
@@ -175,7 +180,7 @@ RowSelectionPlugin.prototype.hasMultiTableSupport = function () {
|
|
175
180
|
* @param {Object=} options Grid configuration object
|
176
181
|
*/
|
177
182
|
RowSelectionPlugin.prototype.initialize = function (host, options) {
|
178
|
-
if
|
183
|
+
if(this._hosts.indexOf(host) >= 0) { return; }
|
179
184
|
this._hosts.push(host);
|
180
185
|
|
181
186
|
host.listen("mousedown", this._onMouseDown);
|
@@ -184,14 +189,12 @@ RowSelectionPlugin.prototype.initialize = function (host, options) {
|
|
184
189
|
host.listen("postSectionDataBinding", this._onPostSectionDataBinding);
|
185
190
|
host.listen("rowPositionChanged", this._onRowPositionChanged);
|
186
191
|
|
187
|
-
|
192
|
+
let wrapper = this.getGridApi(host);
|
188
193
|
if(wrapper) {
|
189
194
|
wrapper.listen("beforeRowRemoved", this._onBeforeRowRemoved);
|
190
195
|
}
|
191
196
|
|
192
197
|
// TODO:: listen to copy and cut event when implement autoCopy config
|
193
|
-
// host.listen("copy", this._onCopy,);
|
194
|
-
// host.listen("cut", this._onCopy);
|
195
198
|
|
196
199
|
this.config(options);
|
197
200
|
|
@@ -204,12 +207,10 @@ RowSelectionPlugin.prototype.initialize = function (host, options) {
|
|
204
207
|
* @param {Object=} host core grid instance
|
205
208
|
*/
|
206
209
|
RowSelectionPlugin.prototype.unload = function (host) {
|
207
|
-
|
208
|
-
if
|
210
|
+
let at = this._hosts.indexOf(host);
|
211
|
+
if(at < 0) { return; }
|
209
212
|
|
210
213
|
host.unlisten("mousedown", this._onMouseDown);
|
211
|
-
host.unlisten("copy", this._onCopy);
|
212
|
-
host.unlisten("cut", this._onCopy);
|
213
214
|
host.unlisten("click", this._onClick);
|
214
215
|
host.unlisten("keydown", this._onKeyDown);
|
215
216
|
host.unlisten("postSectionDataBinding", this._onPostSectionDataBinding);
|
@@ -217,7 +218,7 @@ RowSelectionPlugin.prototype.unload = function (host) {
|
|
217
218
|
|
218
219
|
this._hosts.splice(at, 1);
|
219
220
|
|
220
|
-
if
|
221
|
+
if(!this._hosts.length) {
|
221
222
|
if(this._timerId) {
|
222
223
|
clearTimeout(this._timerId);
|
223
224
|
this._timerId = 0;
|
@@ -232,27 +233,27 @@ RowSelectionPlugin.prototype.unload = function (host) {
|
|
232
233
|
* @param {Object=} options Grid configuration object
|
233
234
|
*/
|
234
235
|
RowSelectionPlugin.prototype.config = function (options) {
|
235
|
-
if
|
236
|
+
if(!options) {
|
236
237
|
return;
|
237
238
|
}
|
238
239
|
|
239
|
-
|
240
|
+
let pluginOptions = options["rowSelection"];
|
240
241
|
|
241
|
-
if
|
242
|
-
if
|
243
|
-
if
|
242
|
+
if(pluginOptions) {
|
243
|
+
if(typeof pluginOptions === "object") {
|
244
|
+
if(pluginOptions["singleSelection"]) {
|
244
245
|
this._singleSelMode = true;
|
245
246
|
}
|
246
|
-
if
|
247
|
+
if(pluginOptions["clickToggle"]) {
|
247
248
|
this._clickToggleMode = true;
|
248
249
|
}
|
249
|
-
if
|
250
|
+
if(pluginOptions["basedOnContent"]) {
|
250
251
|
this._basedOnContent = true;
|
251
252
|
}
|
252
|
-
if
|
253
|
+
if(pluginOptions["selectionField"]) {
|
253
254
|
this._selectionField = pluginOptions["selectionField"];
|
254
255
|
}
|
255
|
-
|
256
|
+
let val = pluginOptions["menuClicked"];
|
256
257
|
if(typeof val === "function"){
|
257
258
|
this._onMenuClicked = val;
|
258
259
|
}
|
@@ -260,13 +261,13 @@ RowSelectionPlugin.prototype.config = function (options) {
|
|
260
261
|
if(val) {
|
261
262
|
this._menuPosition = val;
|
262
263
|
}
|
263
|
-
} else if
|
264
|
+
} else if(pluginOptions === "single") {
|
264
265
|
this._singleSelMode = true;
|
265
266
|
}
|
266
267
|
|
267
268
|
this.addListener(pluginOptions, "selectionChanged");
|
268
269
|
this.addListener(pluginOptions, "beforeSelection");
|
269
|
-
} else if
|
270
|
+
} else if(pluginOptions != null) {
|
270
271
|
this.disable();
|
271
272
|
}
|
272
273
|
};
|
@@ -276,9 +277,9 @@ RowSelectionPlugin.prototype.config = function (options) {
|
|
276
277
|
* @return {!Object}
|
277
278
|
*/
|
278
279
|
RowSelectionPlugin.prototype.getConfigObject = function (gridOptions) {
|
279
|
-
|
280
|
+
let obj = gridOptions || {};
|
280
281
|
|
281
|
-
|
282
|
+
let extOptions = obj.rowSelection;
|
282
283
|
if(!extOptions) {
|
283
284
|
extOptions = obj.rowSelection = {};
|
284
285
|
}
|
@@ -304,12 +305,12 @@ RowSelectionPlugin.prototype.getConfigObject = function (gridOptions) {
|
|
304
305
|
* @param {Object=} activeGrid Grid for taking user key inputs after clearing
|
305
306
|
*/
|
306
307
|
RowSelectionPlugin.prototype.clearAllSelections = function (preserveAnchor, activeGrid) {
|
307
|
-
if
|
308
|
+
if(preserveAnchor == null) {
|
308
309
|
preserveAnchor = true;
|
309
310
|
}
|
310
311
|
this._clearSelectedRows(preserveAnchor);
|
311
312
|
|
312
|
-
if
|
313
|
+
if(activeGrid) {
|
313
314
|
this._activeGrid = activeGrid;
|
314
315
|
}
|
315
316
|
};
|
@@ -342,14 +343,14 @@ RowSelectionPlugin.prototype.getActiveGrid = function () {
|
|
342
343
|
* @return {number} rowIndex of anchor
|
343
344
|
*/
|
344
345
|
RowSelectionPlugin.prototype.getRowAnchor = function (sectRef) {
|
345
|
-
if
|
346
|
-
|
346
|
+
if(this._basedOnContent) {
|
347
|
+
let dv = this._activeGrid ? this._activeGrid.getDataSource() : null;
|
347
348
|
if( dv && this._anchorRowId){
|
348
349
|
return dv.getRowIndex(this._anchorRowId);
|
349
350
|
}
|
350
351
|
} else {
|
351
|
-
|
352
|
-
if
|
352
|
+
let section = this._getSection(sectRef);
|
353
|
+
if(section && section.getRowAnchor){
|
353
354
|
return section.getRowAnchor();
|
354
355
|
}
|
355
356
|
}
|
@@ -361,20 +362,20 @@ RowSelectionPlugin.prototype.getRowAnchor = function (sectRef) {
|
|
361
362
|
* @return {number|null}
|
362
363
|
*/
|
363
364
|
RowSelectionPlugin.prototype.getFirstSelectedIndex = function (sectRef) {
|
364
|
-
|
365
|
-
if
|
365
|
+
let section = this._getSection(sectRef);
|
366
|
+
if(!section) {
|
366
367
|
return null;
|
367
|
-
} else if
|
368
|
-
|
369
|
-
if
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
for
|
368
|
+
} else if(this._basedOnContent) {
|
369
|
+
let dv = this._activeGrid ? this._activeGrid.getDataSource() : null;
|
370
|
+
if(!dv) return null;
|
371
|
+
|
372
|
+
let rids = dv.getVisibleRowIds(true);
|
373
|
+
let rows = dv.getMultipleRowData(rids);
|
374
|
+
let count = rows.length;
|
375
|
+
let dataRow;
|
376
|
+
for(let rowIndex = 0; rowIndex < count; rowIndex++) {
|
376
377
|
dataRow = this._rowGetter(rows[rowIndex]);
|
377
|
-
if
|
378
|
+
if(dataRow && dataRow[this._selectionField]) {
|
378
379
|
return rowIndex;
|
379
380
|
}
|
380
381
|
}
|
@@ -389,20 +390,20 @@ RowSelectionPlugin.prototype.getFirstSelectedIndex = function (sectRef) {
|
|
389
390
|
* @return {number|null}
|
390
391
|
*/
|
391
392
|
RowSelectionPlugin.prototype.getLastSelectedIndex = function (sectRef) {
|
392
|
-
|
393
|
-
if
|
393
|
+
let section = this._getSection(sectRef);
|
394
|
+
if(!section) {
|
394
395
|
return null;
|
395
|
-
} else if
|
396
|
-
|
397
|
-
if
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
for
|
396
|
+
} else if(this._basedOnContent) {
|
397
|
+
let dv = this._activeGrid ? this._activeGrid.getDataSource() : null;
|
398
|
+
if(!dv) return null;
|
399
|
+
|
400
|
+
let rids = dv.getVisibleRowIds(true);
|
401
|
+
let rows = dv.getMultipleRowData(rids);
|
402
|
+
let count = rows.length;
|
403
|
+
let dataRow;
|
404
|
+
for(let rowIndex = count - 1; rowIndex >= 0; rowIndex--) {
|
404
405
|
dataRow = this._rowGetter(rows[rowIndex]);
|
405
|
-
if
|
406
|
+
if(dataRow && dataRow[this._selectionField]) {
|
406
407
|
return rowIndex;
|
407
408
|
}
|
408
409
|
}
|
@@ -418,21 +419,21 @@ RowSelectionPlugin.prototype.getLastSelectedIndex = function (sectRef) {
|
|
418
419
|
* @return {Array.<number>}
|
419
420
|
*/
|
420
421
|
RowSelectionPlugin.prototype.getSelectedRows = function (sectRef) {
|
421
|
-
|
422
|
-
if
|
422
|
+
let section = this._getSection(sectRef);
|
423
|
+
if(!section) {
|
423
424
|
return null;
|
424
|
-
} else if
|
425
|
-
|
426
|
-
if
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
for
|
425
|
+
} else if(this._basedOnContent) {
|
426
|
+
let dv = this._activeGrid ? this._activeGrid.getDataSource() : null;
|
427
|
+
if(!dv) return null;
|
428
|
+
|
429
|
+
let rids = dv.getVisibleRowIds(true);
|
430
|
+
let rows = dv.getMultipleRowData(rids);
|
431
|
+
let count = rows.length;
|
432
|
+
let selectedRows = [];
|
433
|
+
let dataRow;
|
434
|
+
for(let rowIndex = 0; rowIndex < count; rowIndex++) {
|
434
435
|
dataRow = this._rowGetter(rows[rowIndex]);
|
435
|
-
if
|
436
|
+
if(dataRow && dataRow[this._selectionField]) {
|
436
437
|
selectedRows.push(rowIndex);
|
437
438
|
}
|
438
439
|
}
|
@@ -447,16 +448,16 @@ RowSelectionPlugin.prototype.getSelectedRows = function (sectRef) {
|
|
447
448
|
* @return {Array.<string>}
|
448
449
|
*/
|
449
450
|
RowSelectionPlugin.prototype.getSelectedRowIds = function (sectRef) {
|
450
|
-
|
451
|
-
|
451
|
+
let rids = null;
|
452
|
+
let len, i;
|
452
453
|
|
453
|
-
|
454
|
-
if
|
455
|
-
|
456
|
-
|
454
|
+
let selRows = this.getSelectedRows(sectRef);
|
455
|
+
if(selRows) {
|
456
|
+
let dv = this._activeGrid.getDataSource();
|
457
|
+
let rowIds = dv.getVisibleRowIds(true);
|
457
458
|
len = selRows.length;
|
458
459
|
rids = new Array(len);
|
459
|
-
for
|
460
|
+
for(i = 0; i < len; ++i) {
|
460
461
|
rids[i] = rowIds[selRows[i]] || "";
|
461
462
|
}
|
462
463
|
}
|
@@ -468,10 +469,10 @@ RowSelectionPlugin.prototype.getSelectedRowIds = function (sectRef) {
|
|
468
469
|
* @return {number}
|
469
470
|
*/
|
470
471
|
RowSelectionPlugin.prototype.getSelectedRowCount = function (sectRef) {
|
471
|
-
|
472
|
-
if
|
473
|
-
if
|
474
|
-
|
472
|
+
let section = this._getSection(sectRef);
|
473
|
+
if(!section) return 0;
|
474
|
+
if(this._basedOnContent) {
|
475
|
+
let selectedRows = this.getSelectedRows();
|
475
476
|
return selectedRows ? selectedRows.length : 0;
|
476
477
|
} else {
|
477
478
|
return section.getSelectedRowCount();
|
@@ -483,8 +484,8 @@ RowSelectionPlugin.prototype.getSelectedRowCount = function (sectRef) {
|
|
483
484
|
* @param {Object=} sectRef Grid SectionReference
|
484
485
|
*/
|
485
486
|
RowSelectionPlugin.prototype.setSelectedRow = function (rowIndex, opt_select, sectRef) {
|
486
|
-
|
487
|
-
if
|
487
|
+
let section = this._getSection(sectRef);
|
488
|
+
if(!section) { return; }
|
488
489
|
this._sectionSetSelectedRow(section, rowIndex, opt_select);
|
489
490
|
};
|
490
491
|
/**
|
@@ -495,11 +496,11 @@ RowSelectionPlugin.prototype.setSelectedRow = function (rowIndex, opt_select, se
|
|
495
496
|
* @return {boolean}
|
496
497
|
*/
|
497
498
|
RowSelectionPlugin.prototype.selectSingleRow = function (rowIndex, sectRef, activeGrid) {
|
498
|
-
if
|
499
|
+
if(!(rowIndex >= 0)) { return false; }
|
499
500
|
|
500
501
|
// 1. first of all let's clear selectedRows of prevGrid
|
501
|
-
|
502
|
-
if
|
502
|
+
let prevGrid = activeGrid ? this._activeGrid : null;
|
503
|
+
if(prevGrid) {
|
503
504
|
this._clearSelectedRows();
|
504
505
|
|
505
506
|
// 2. after clear selection let switch active grid
|
@@ -507,14 +508,14 @@ RowSelectionPlugin.prototype.selectSingleRow = function (rowIndex, sectRef, acti
|
|
507
508
|
}
|
508
509
|
|
509
510
|
// 3. now active grid is switch let's normally select row
|
510
|
-
|
511
|
-
if
|
511
|
+
let section = this._getSection(sectRef); // TODO: Check if the given section is in the active grid
|
512
|
+
if(this._selectSingleRow(section, rowIndex)) {
|
512
513
|
this._scrollToRow(rowIndex);
|
513
514
|
return true;
|
514
515
|
}
|
515
516
|
// 4. in case fail to perform _selectSingleRow
|
516
517
|
// we will turn back _activeGrid to prevGrid
|
517
|
-
else if
|
518
|
+
else if(prevGrid) {
|
518
519
|
this._activeGrid = prevGrid;
|
519
520
|
}
|
520
521
|
|
@@ -524,17 +525,17 @@ RowSelectionPlugin.prototype.selectSingleRow = function (rowIndex, sectRef, acti
|
|
524
525
|
* @param {Object=} activeGrid core grid instance
|
525
526
|
*/
|
526
527
|
RowSelectionPlugin.prototype.selectAllRows = function (activeGrid) {
|
527
|
-
if
|
528
|
+
if(activeGrid) {
|
528
529
|
this._activeGrid = activeGrid;
|
529
|
-
} else if
|
530
|
+
} else if(!this._activeGrid) {
|
530
531
|
this._activeGrid = this._hosts[0];
|
531
532
|
}
|
532
533
|
|
533
|
-
if
|
534
|
-
|
535
|
-
for
|
534
|
+
if(this._activeGrid) {
|
535
|
+
let sections = this._activeGrid.getAllSections("content");
|
536
|
+
for(let i = sections.length; --i >= 0;) {
|
536
537
|
this._selectRowRange(null, null, sections[i]);
|
537
|
-
if
|
538
|
+
if(i == 0) {
|
538
539
|
this._anchorSection = sections[i];
|
539
540
|
}
|
540
541
|
}
|
@@ -551,7 +552,7 @@ RowSelectionPlugin.prototype.selectAllRows = function (activeGrid) {
|
|
551
552
|
RowSelectionPlugin.prototype.selectRowRange = function (rowIndex, length, sectRef, opt_scrollToRow) {
|
552
553
|
this._selectRowRange(rowIndex, length, sectRef);
|
553
554
|
|
554
|
-
if
|
555
|
+
if(opt_scrollToRow) {
|
555
556
|
this._scrollToRow(rowIndex);
|
556
557
|
}
|
557
558
|
this._updateMenuIcon();
|
@@ -581,9 +582,9 @@ RowSelectionPlugin.prototype.disableMultiSelection = function (disabled) {
|
|
581
582
|
* @param {Event} e
|
582
583
|
*/
|
583
584
|
RowSelectionPlugin.prototype._onClick = function (e) {
|
584
|
-
if
|
585
|
+
if(this._pendingClickIndex >= 0 && this._anchorSection) {
|
585
586
|
this._selectSingleRow(this._anchorSection, this._pendingClickIndex);
|
586
|
-
|
587
|
+
let host = this.getRelativeGrid(e);
|
587
588
|
this._clearPendingClickIndex(host);
|
588
589
|
|
589
590
|
if(!this._basedOnContent) { // Protect against rowPositionChanged and postBindingSection event
|
@@ -599,7 +600,7 @@ RowSelectionPlugin.prototype._onClick = function (e) {
|
|
599
600
|
* @param {Object=} mouseEvt
|
600
601
|
*/
|
601
602
|
RowSelectionPlugin.prototype.selectByMouse = function (rowIndex, mouseEvt) {
|
602
|
-
|
603
|
+
let eventObj = this._mockMouseEvent(0, rowIndex, mouseEvt);
|
603
604
|
this._onMouseDown(eventObj);
|
604
605
|
};
|
605
606
|
|
@@ -610,7 +611,7 @@ RowSelectionPlugin.prototype.selectByMouse = function (rowIndex, mouseEvt) {
|
|
610
611
|
* @param {Object=} keyboardEvt
|
611
612
|
*/
|
612
613
|
RowSelectionPlugin.prototype.selectByKey = function (keyCode, keyboardEvt) {
|
613
|
-
|
614
|
+
let eventObj = this._mockKeyboardEvent(keyCode, keyboardEvt);
|
614
615
|
this._onKeyDown(eventObj);
|
615
616
|
};
|
616
617
|
|
@@ -624,71 +625,71 @@ RowSelectionPlugin.prototype.selectByKey = function (keyCode, keyboardEvt) {
|
|
624
625
|
* @param {Event} e
|
625
626
|
*/
|
626
627
|
RowSelectionPlugin.prototype._onMouseDown = function (e) {
|
627
|
-
if
|
628
|
+
if(this._disabled) {
|
628
629
|
return;
|
629
630
|
}
|
630
|
-
if
|
631
|
-
if
|
631
|
+
if(e.button === 2) { // Right click
|
632
|
+
if(e.shiftKey || e.ctrlKey) {
|
632
633
|
return;
|
633
634
|
}
|
634
635
|
}
|
635
636
|
|
636
|
-
|
637
|
+
let host = this.getRelativeGrid(e);
|
637
638
|
|
638
639
|
this._clearPendingClickIndex(host);
|
639
640
|
|
640
|
-
if
|
641
|
+
if(!host) {
|
641
642
|
return;
|
642
643
|
}
|
643
644
|
|
644
|
-
|
645
|
-
if
|
646
|
-
if
|
647
|
-
|
648
|
-
if
|
649
|
-
if
|
645
|
+
let ctx = host.getRelativePosition(e);
|
646
|
+
if(!ctx["hit"] || ctx["sectionType"] !== "content") { return; }
|
647
|
+
if(e.button === 2) { // Right click at the selected column should override clicking row to select;
|
648
|
+
let csp = this._getPlugin("ColumnSelectionPlugin");
|
649
|
+
if(csp && csp["isEnabled"]()) {
|
650
|
+
if(csp["isSelectedColumn"](ctx["colIndex"])) {
|
650
651
|
return;
|
651
652
|
}
|
652
653
|
}
|
653
654
|
}
|
654
|
-
|
655
|
-
|
656
|
-
if
|
655
|
+
let dv = ctx["dataSource"];
|
656
|
+
let rowIndex = ctx["rowIndex"];
|
657
|
+
if(this._basedOnContent) {
|
657
658
|
// ignore group header row
|
658
|
-
|
659
|
-
if
|
659
|
+
let dataRow = this._getRow(dv, rowIndex);
|
660
|
+
if(!dataRow) {
|
660
661
|
return;
|
661
662
|
}
|
662
663
|
}
|
663
664
|
|
664
|
-
if
|
665
|
+
if(this._dispatchBeforeSelection(e, ctx)) {
|
665
666
|
return;
|
666
667
|
}
|
667
668
|
|
668
|
-
|
669
|
-
|
670
|
-
|
669
|
+
let singleSelection = this._singleSelMode || !this._activeGrid || (this._activeGrid !== host); // New grid is clicked
|
670
|
+
let section = ctx["section"];
|
671
|
+
let prevSel = section.isSelectedRow(rowIndex);
|
671
672
|
|
672
|
-
if
|
673
|
-
if
|
673
|
+
if(!singleSelection) {
|
674
|
+
if(e.shiftKey) { // Shift + Click: selects every rows start from anchor to clicked point. Anchor point doesn't change.
|
674
675
|
this._selectFromAnchorToTarget(section, rowIndex);
|
675
|
-
} else if
|
676
|
+
} else if((e.ctrlKey && !IS_MAC) || (IS_MAC && !e.ctrlKey && e.metaKey)) { // Ctrl(windows)/Command(macOS) + Click: additionally selects a row without deselect all others.
|
676
677
|
this._sectionSetSelectedRow(section, rowIndex, !prevSel);
|
677
678
|
} else {
|
678
679
|
singleSelection = true;
|
679
680
|
}
|
680
681
|
}
|
681
682
|
|
682
|
-
if
|
683
|
+
if(singleSelection) { // Click: selects a single row
|
683
684
|
this._anchorSection = section;
|
684
|
-
if
|
685
|
+
if(prevSel) { // Click on the selected row
|
685
686
|
this._setPendingClickIndex(rowIndex, host); // Delay the operation to allow drag and drop operation
|
686
687
|
return;
|
687
688
|
} else { // Perform single click immediately
|
688
|
-
|
689
|
+
let prevGrid = this._activeGrid;
|
689
690
|
|
690
691
|
// clear selection row in prevGrid first if prev and current host not the same
|
691
|
-
if
|
692
|
+
if(prevGrid !== host) {
|
692
693
|
this._clearSelectedRows(true);
|
693
694
|
this._activeGrid = host;
|
694
695
|
}
|
@@ -714,7 +715,7 @@ RowSelectionPlugin.prototype._onMouseDown = function (e) {
|
|
714
715
|
* @param {Event} e
|
715
716
|
*/
|
716
717
|
RowSelectionPlugin.prototype._onMouseMove = function (e) {
|
717
|
-
|
718
|
+
let host = this.getRelativeGrid(e);
|
718
719
|
this._clearPendingClickIndex(host);
|
719
720
|
};
|
720
721
|
|
@@ -741,7 +742,7 @@ RowSelectionPlugin.prototype._clearPendingClickIndex = function (host) {
|
|
741
742
|
* @param {KeyboardEvent} e
|
742
743
|
*/
|
743
744
|
RowSelectionPlugin.prototype._onKeyDown = function (e) {
|
744
|
-
if
|
745
|
+
if(!this._activeGrid) { return; }
|
745
746
|
|
746
747
|
//Arrow Up/Down move a row selection up/down by one.
|
747
748
|
//Arrow Up/Down and shift additionally select a row that is the one before first or after last selected row.
|
@@ -761,10 +762,10 @@ RowSelectionPlugin.prototype._onKeyDown = function (e) {
|
|
761
762
|
this._selectByKey(-1, e, true);
|
762
763
|
break;
|
763
764
|
case 37: //Left arrow
|
764
|
-
if
|
765
|
+
if(this._dispatchBeforeSelection(e)) {
|
765
766
|
return;
|
766
767
|
}
|
767
|
-
if
|
768
|
+
if(this._gotoPrevGrid()) {
|
768
769
|
EventDispatcher.preventDefault(e);
|
769
770
|
}
|
770
771
|
break;
|
@@ -772,10 +773,10 @@ RowSelectionPlugin.prototype._onKeyDown = function (e) {
|
|
772
773
|
this._selectByKey(-1, e);
|
773
774
|
break;
|
774
775
|
case 39: //Right arrow
|
775
|
-
if
|
776
|
+
if(this._dispatchBeforeSelection(e)) {
|
776
777
|
return;
|
777
778
|
}
|
778
|
-
if
|
779
|
+
if(this._gotoNextGrid()) {
|
779
780
|
EventDispatcher.preventDefault(e);
|
780
781
|
}
|
781
782
|
break;
|
@@ -803,7 +804,7 @@ RowSelectionPlugin.prototype._onReselection = function (e) {
|
|
803
804
|
this._timerId = 0;
|
804
805
|
|
805
806
|
if(this._pendingSelection != null) {
|
806
|
-
|
807
|
+
let firstSel = this.getFirstSelectedIndex();
|
807
808
|
if(firstSel == null) { // Only perform reselection if the last selection has been removed
|
808
809
|
this.setSelectedRow(this._pendingSelection, true);
|
809
810
|
}
|
@@ -812,45 +813,25 @@ RowSelectionPlugin.prototype._onReselection = function (e) {
|
|
812
813
|
this._pendingSelection = null;
|
813
814
|
};
|
814
815
|
|
815
|
-
/** @private
|
816
|
-
* @param {Event} e
|
817
|
-
*/
|
818
|
-
RowSelectionPlugin.prototype._onCopy = function (e) {
|
819
|
-
var clipboardData, format;
|
820
|
-
if (e.clipboardData) {
|
821
|
-
clipboardData = e.clipboardData;
|
822
|
-
format = "text/plain";
|
823
|
-
} else {
|
824
|
-
clipboardData = window.clipboardData;
|
825
|
-
format = "Text";
|
826
|
-
}
|
827
|
-
// Set clipboards data to copy api.
|
828
|
-
var txt = this.getSelectedText();
|
829
|
-
if (txt) {
|
830
|
-
clipboardData.setData(format, txt);
|
831
|
-
}
|
832
|
-
e.preventDefault();
|
833
|
-
};
|
834
|
-
|
835
816
|
/** @private
|
836
817
|
* @param {Object} e postSectionDataBinding event context
|
837
818
|
*/
|
838
819
|
RowSelectionPlugin.prototype._onPostSectionDataBinding = function (e) {
|
839
|
-
if
|
820
|
+
if(!this._basedOnContent
|
840
821
|
|| "content" !== e.sectionType
|
841
822
|
|| !this._activeGrid) {
|
842
823
|
return;
|
843
824
|
}
|
844
|
-
|
845
|
-
|
825
|
+
let section = e.section;
|
826
|
+
let dv = e.dataSource;
|
846
827
|
|
847
|
-
|
828
|
+
let field = this._selectionField;
|
848
829
|
section.clearSelectedRows();
|
849
830
|
|
850
|
-
|
851
|
-
|
852
|
-
for
|
853
|
-
|
831
|
+
let fromR = section.getFirstIndexInView();
|
832
|
+
let toR = section.getLastIndexInView();
|
833
|
+
for(let r = fromR; r <= toR; ++r) {
|
834
|
+
let dataRow = this._rowGetter(dv.getRowDataAt(r));
|
854
835
|
if(dataRow) {
|
855
836
|
if(dataRow[field]) {
|
856
837
|
section.setSelectedRow(r, true);
|
@@ -881,25 +862,25 @@ RowSelectionPlugin.prototype._onRowPositionChanged = function (e) {
|
|
881
862
|
*/
|
882
863
|
RowSelectionPlugin.prototype.getSelectedText = function () {
|
883
864
|
// work only with composit and realtime
|
884
|
-
if
|
865
|
+
if(!this._compositeGrid && !this._realTimeGrid) return "";
|
885
866
|
|
886
|
-
|
887
|
-
|
888
|
-
|
889
|
-
|
890
|
-
|
891
|
-
for
|
892
|
-
|
893
|
-
|
867
|
+
let selectedRows = this.getSelectedRows();
|
868
|
+
let rowCount = selectedRows.length;
|
869
|
+
let columnCount = this.getColumnCount();
|
870
|
+
let text = "";
|
871
|
+
let dv = this._activeGrid.getDataSource();
|
872
|
+
for(let i = 0; i < rowCount; i++) {
|
873
|
+
let rowIndex = selectedRows[i];
|
874
|
+
let rowData = this._getRow(dv, rowIndex);
|
894
875
|
|
895
|
-
if
|
896
|
-
if
|
876
|
+
if(rowData) {
|
877
|
+
if(text.length) text += "\n"; // break line before write in case text has content
|
897
878
|
|
898
879
|
// data row
|
899
|
-
for
|
900
|
-
if
|
880
|
+
for(let colIndex = 0; colIndex < columnCount; colIndex++) {
|
881
|
+
if(colIndex > 0) text += "\t"; // separate each cell content with tab
|
901
882
|
// column fields are available on compositeGrid and realTimeGrid level
|
902
|
-
|
883
|
+
let cField = this._getField(colIndex);
|
903
884
|
text += prepareTSVContent(rowData[cField]);
|
904
885
|
}
|
905
886
|
}
|
@@ -912,21 +893,21 @@ RowSelectionPlugin.prototype.getSelectedText = function () {
|
|
912
893
|
* @return {Object} ILayoutGrid
|
913
894
|
*/
|
914
895
|
RowSelectionPlugin.prototype._getSection = function (sectRef) {
|
915
|
-
if
|
896
|
+
if(!this._activeGrid) {
|
916
897
|
this._activeGrid = this._hosts[0];
|
917
|
-
if
|
898
|
+
if(this._activeGrid) {
|
918
899
|
this._anchorSection = this._activeGrid.getSection("content");
|
919
|
-
if
|
900
|
+
if(!this._anchorSection) {
|
920
901
|
this._activeGrid = null;
|
921
902
|
}
|
922
903
|
}
|
923
904
|
}
|
924
|
-
if
|
905
|
+
if(sectRef) {
|
925
906
|
return this._activeGrid.getSection(sectRef);
|
926
907
|
}
|
927
908
|
|
928
|
-
if
|
929
|
-
if
|
909
|
+
if(this._anchorSection) {
|
910
|
+
if(!this._anchorSection.getElement()) { // The section may has been disposed.
|
930
911
|
this._anchorSection = null;
|
931
912
|
}
|
932
913
|
}
|
@@ -938,23 +919,23 @@ RowSelectionPlugin.prototype._getSection = function (sectRef) {
|
|
938
919
|
* @param {boolean=} preserveAnchor
|
939
920
|
*/
|
940
921
|
RowSelectionPlugin.prototype._clearSelectedRows = function (preserveAnchor) { // Slow
|
941
|
-
if
|
922
|
+
if(!this._activeGrid) {
|
942
923
|
return;
|
943
924
|
}
|
944
|
-
if
|
945
|
-
|
946
|
-
if
|
947
|
-
|
925
|
+
if(this._basedOnContent) {
|
926
|
+
let dv = this._activeGrid.getDataSource();
|
927
|
+
if(dv) {
|
928
|
+
let dt = dv.getDataSource();
|
948
929
|
this._setColumnData(dt, this._selectionField, false);
|
949
930
|
}
|
950
931
|
} else {
|
951
|
-
|
952
|
-
for
|
932
|
+
let sections = this._activeGrid.getAllSections("content");
|
933
|
+
for(let i = sections.length; --i >= 0;) {
|
953
934
|
this._sectionClearSelectedRows(sections[i], preserveAnchor);
|
954
935
|
}
|
955
936
|
}
|
956
937
|
|
957
|
-
if
|
938
|
+
if(!preserveAnchor) {
|
958
939
|
this._anchorSection = null;
|
959
940
|
}
|
960
941
|
this._clearPendingClickIndex(this._activeGrid);
|
@@ -969,38 +950,38 @@ RowSelectionPlugin.prototype._clearSelectedRows = function (preserveAnchor) { //
|
|
969
950
|
RowSelectionPlugin.prototype._selectByKey = function (direction, e, pageKey) {
|
970
951
|
e.preventDefault();
|
971
952
|
|
972
|
-
if
|
953
|
+
if(!this._anchorSection) { return; }
|
973
954
|
|
974
955
|
if(this._activeGrid != null){
|
975
956
|
this._activeGrid.focus();
|
976
957
|
}
|
977
958
|
|
978
|
-
|
979
|
-
|
980
|
-
|
981
|
-
if
|
982
|
-
|
983
|
-
if
|
984
|
-
if
|
959
|
+
let shiftKey = e.shiftKey;
|
960
|
+
let next = 0;
|
961
|
+
let rowLimit = this._anchorSection.getRowCount() - 1;
|
962
|
+
if(pageKey) {
|
963
|
+
let info = this._activeGrid.getVScrollView();
|
964
|
+
if(direction === -1) { // Up
|
965
|
+
if(info) {
|
985
966
|
next = this.getFirstSelectedIndex(this._anchorSection) <= info["firstFullRow"] ? info["prevPageRowIndex"] : info["firstFullRow"];
|
986
967
|
}
|
987
968
|
} else {
|
988
|
-
if
|
969
|
+
if(info) {
|
989
970
|
next = this.getLastSelectedIndex(this._anchorSection) >= info["lastFullRow"] ? info["nextPageRowIndex"] : info["lastFullRow"];
|
990
971
|
} else {
|
991
972
|
next = rowLimit;
|
992
973
|
}
|
993
974
|
}
|
994
975
|
} else {
|
995
|
-
if
|
976
|
+
if(direction === -1) {
|
996
977
|
next = this.getFirstSelectedIndex(this._anchorSection) + direction;
|
997
978
|
} else {
|
998
979
|
next = this.getLastSelectedIndex(this._anchorSection) + direction;
|
999
980
|
}
|
1000
981
|
}
|
1001
|
-
if
|
1002
|
-
|
1003
|
-
if
|
982
|
+
if(next < 0) {
|
983
|
+
let csp = this._getPlugin("ColumnSelectionPlugin");
|
984
|
+
if(!shiftKey && csp && csp["isEnabled"]()) {
|
1004
985
|
csp["selectSingleColumn"](null, this._activeGrid);
|
1005
986
|
|
1006
987
|
this.clearAllSelections();
|
@@ -1008,16 +989,16 @@ RowSelectionPlugin.prototype._selectByKey = function (direction, e, pageKey) {
|
|
1008
989
|
}
|
1009
990
|
this._scrollToRow(0);
|
1010
991
|
return;
|
1011
|
-
} else if
|
992
|
+
} else if(next > rowLimit) {
|
1012
993
|
this._scrollToRow(rowLimit);
|
1013
994
|
return;
|
1014
995
|
}
|
1015
996
|
|
1016
|
-
if
|
997
|
+
if(this._dispatchBeforeSelection(e)) {
|
1017
998
|
return;
|
1018
999
|
}
|
1019
1000
|
|
1020
|
-
if
|
1001
|
+
if(shiftKey && !this._singleSelMode) {
|
1021
1002
|
this._selectFromAnchorToTarget(this._anchorSection, next);
|
1022
1003
|
} else {
|
1023
1004
|
this._selectSingleRow(this._anchorSection, next);
|
@@ -1036,14 +1017,14 @@ RowSelectionPlugin.prototype._selectByKey = function (direction, e, pageKey) {
|
|
1036
1017
|
*/
|
1037
1018
|
RowSelectionPlugin.prototype._sectionSetSelectedRow = function (section, rowIndex, isSelect) {
|
1038
1019
|
// set selection state to rowData when _basedOnContent === true
|
1039
|
-
if
|
1040
|
-
|
1020
|
+
if(this._basedOnContent) {
|
1021
|
+
let dv = (this._activeGrid) ? this._activeGrid.getDataSource() : null;
|
1041
1022
|
|
1042
|
-
if
|
1043
|
-
|
1044
|
-
if
|
1023
|
+
if(dv) {
|
1024
|
+
let dataRow = this._getRow(dv, rowIndex);
|
1025
|
+
if(dataRow) {
|
1045
1026
|
this._setData(dv, rowIndex, this._selectionField, isSelect);
|
1046
|
-
if
|
1027
|
+
if(isSelect) this._anchorRowId = dv.getRowId(rowIndex);
|
1047
1028
|
}
|
1048
1029
|
}
|
1049
1030
|
} else {
|
@@ -1061,23 +1042,23 @@ RowSelectionPlugin.prototype._selectRangeOnSection = function (section, rowIndex
|
|
1061
1042
|
if(rowIndex == null) {
|
1062
1043
|
rowIndex = 0;
|
1063
1044
|
}
|
1064
|
-
if
|
1065
|
-
|
1045
|
+
if(this._basedOnContent) { // TODO: handle the case where section is not content section
|
1046
|
+
let dv = (this._activeGrid) ? this._activeGrid.getDataSource() : null;
|
1066
1047
|
|
1067
|
-
if
|
1068
|
-
|
1048
|
+
if(dv) {
|
1049
|
+
let rids = dv.getVisibleRowIds(true);
|
1069
1050
|
if(length == null) {
|
1070
1051
|
length = rids.length;
|
1071
1052
|
}
|
1072
|
-
|
1053
|
+
let toRowIndex = rowIndex + length;
|
1073
1054
|
if(toRowIndex > rids.length) {
|
1074
1055
|
toRowIndex = rids.length;
|
1075
1056
|
}
|
1076
|
-
|
1077
|
-
|
1078
|
-
for
|
1079
|
-
|
1080
|
-
if
|
1057
|
+
let ridList = [];
|
1058
|
+
let valueList = [];
|
1059
|
+
for(let r = rowIndex; r < toRowIndex; r++) {
|
1060
|
+
let dataRow = this._getRow(dv, r);
|
1061
|
+
if(dataRow) {
|
1081
1062
|
ridList.push(rids[r]);
|
1082
1063
|
valueList.push(true);
|
1083
1064
|
}
|
@@ -1098,20 +1079,20 @@ RowSelectionPlugin.prototype._selectRangeOnSection = function (section, rowIndex
|
|
1098
1079
|
* @param {boolean=} preserveAnchor
|
1099
1080
|
*/
|
1100
1081
|
RowSelectionPlugin.prototype._sectionClearSelectedRows = function (section, preserveAnchor) {
|
1101
|
-
if
|
1102
|
-
|
1103
|
-
if
|
1104
|
-
|
1105
|
-
if
|
1106
|
-
|
1107
|
-
|
1108
|
-
for
|
1082
|
+
if(this._basedOnContent) {
|
1083
|
+
let selectedRowIds = this.getSelectedRowIds();
|
1084
|
+
if(selectedRowIds) {
|
1085
|
+
let dv = (this._activeGrid) ? this._activeGrid.getDataSource() : null;
|
1086
|
+
if(dv) {
|
1087
|
+
let len = selectedRowIds.length;
|
1088
|
+
let valueList = new Array(len);
|
1089
|
+
for(let i = 0; i < len; i++) {
|
1109
1090
|
valueList[i] = false;
|
1110
1091
|
}
|
1111
1092
|
this._setColumnData(dv, this._selectionField, valueList, selectedRowIds);
|
1112
1093
|
}
|
1113
1094
|
}
|
1114
|
-
if
|
1095
|
+
if(!preserveAnchor) {
|
1115
1096
|
this._anchorRowId = "";
|
1116
1097
|
}
|
1117
1098
|
} else {
|
@@ -1126,7 +1107,7 @@ RowSelectionPlugin.prototype._sectionClearSelectedRows = function (section, pres
|
|
1126
1107
|
* @return {boolean}
|
1127
1108
|
*/
|
1128
1109
|
RowSelectionPlugin.prototype._selectSingleRow = function (section, rowIndex) {
|
1129
|
-
if
|
1110
|
+
if(!section) { return false; }
|
1130
1111
|
|
1131
1112
|
this._clearSelectedRows(); // Deselect all rows
|
1132
1113
|
this._sectionSetSelectedRow(section, rowIndex, true); // The anchor row is set
|
@@ -1142,40 +1123,40 @@ RowSelectionPlugin.prototype._updateMenuIcon = function () {
|
|
1142
1123
|
if(!this._onMenuClicked) {
|
1143
1124
|
return false;
|
1144
1125
|
}
|
1145
|
-
|
1146
|
-
|
1126
|
+
let host = this._activeGrid;
|
1127
|
+
let startRowIndex = this.getFirstSelectedIndex();
|
1147
1128
|
if(startRowIndex == null || !host) { // have no selected rows
|
1148
1129
|
return false;
|
1149
1130
|
}
|
1150
|
-
|
1151
|
-
|
1131
|
+
let endRowIndex = this.getLastSelectedIndex();
|
1132
|
+
let parentEl = host.getParent().parentNode;
|
1152
1133
|
|
1153
1134
|
if(!this._menuButton) {
|
1154
1135
|
this._menuButton = document.createElement("div");
|
1155
1136
|
this._menuButton.classList.add("row-selection-menu");
|
1156
1137
|
this._menuButton.addEventListener("click", this._onMenuClicked);
|
1157
|
-
|
1138
|
+
let coralIcon = document.createElement("ef-icon");
|
1158
1139
|
coralIcon.icon = "most-detail";
|
1159
1140
|
this._menuButton.appendChild(coralIcon);
|
1160
1141
|
}
|
1161
1142
|
|
1162
1143
|
parentEl.appendChild(this._menuButton);
|
1163
1144
|
|
1164
|
-
|
1165
|
-
|
1145
|
+
let menuIconSize = 28; // Currently support 28 and 24 pixel only
|
1146
|
+
let rowRect = host.getRowRect(startRowIndex, endRowIndex);
|
1166
1147
|
|
1167
1148
|
if( rowRect.scrollViewSize <= rowRect.top || rowRect.height + rowRect.top <= 0) { // hide icon when have no selection in view both left and right
|
1168
1149
|
this._clearMenuIcon();
|
1169
1150
|
return false;
|
1170
1151
|
}
|
1171
1152
|
|
1172
|
-
|
1173
|
-
|
1153
|
+
let leftOffset = rowRect.left + rowRect.width;
|
1154
|
+
let topOffset = rowRect.top + rowRect.scrollViewTop;
|
1174
1155
|
if(this._menuPosition !== "outside") {
|
1175
1156
|
menuIconSize = 24;
|
1176
1157
|
this._menuButton.classList.add("row-selection-menu-inside");
|
1177
1158
|
leftOffset = rowRect.left + rowRect.width - menuIconSize;
|
1178
|
-
topOffset = rowRect.top
|
1159
|
+
topOffset = rowRect.top + rowRect.scrollViewTop - menuIconSize;
|
1179
1160
|
|
1180
1161
|
if(rowRect.top < menuIconSize) {
|
1181
1162
|
topOffset = rowRect.top + rowRect.scrollViewTop;
|
@@ -1208,8 +1189,8 @@ RowSelectionPlugin.prototype._clearMenuIcon = function () {
|
|
1208
1189
|
* @param {Object=} sectRef Grid SectionReference
|
1209
1190
|
*/
|
1210
1191
|
RowSelectionPlugin.prototype._selectRowRange = function (rowIndex, length, sectRef) {
|
1211
|
-
|
1212
|
-
if
|
1192
|
+
let section = this._getSection(sectRef);
|
1193
|
+
if(section) {
|
1213
1194
|
this._selectRangeOnSection(section, rowIndex, length);
|
1214
1195
|
}
|
1215
1196
|
};
|
@@ -1219,23 +1200,23 @@ RowSelectionPlugin.prototype._selectRowRange = function (rowIndex, length, sectR
|
|
1219
1200
|
* @param {number} rowIndex
|
1220
1201
|
*/
|
1221
1202
|
RowSelectionPlugin.prototype._selectFromAnchorToTarget = function (section, rowIndex) {
|
1222
|
-
if
|
1223
|
-
|
1224
|
-
if
|
1203
|
+
if(this._anchorSection === section) {
|
1204
|
+
let anchorRow = this.getRowAnchor(this._anchorSection);
|
1205
|
+
if(anchorRow !== rowIndex) {
|
1225
1206
|
this._clearSelectedRows(true); // Keep anchor section
|
1226
1207
|
|
1227
1208
|
// WORKAROUND: To support negative count
|
1228
|
-
|
1229
|
-
|
1230
|
-
|
1231
|
-
if
|
1209
|
+
let direction = 1; // down
|
1210
|
+
let startingRow = anchorRow;
|
1211
|
+
let selectionCount = rowIndex - anchorRow;
|
1212
|
+
if(selectionCount < 0) {
|
1232
1213
|
direction = -1; // up
|
1233
1214
|
startingRow = rowIndex;
|
1234
1215
|
}
|
1235
1216
|
|
1236
1217
|
this._selectRangeOnSection(section, startingRow, (selectionCount * direction) + 1);
|
1237
1218
|
|
1238
|
-
if
|
1219
|
+
if(!this._basedOnContent && this._anchorSection.setRowAnchor) {
|
1239
1220
|
//Make sure that the anchor stays at the same position
|
1240
1221
|
this._anchorSection.setRowAnchor(anchorRow);
|
1241
1222
|
}
|
@@ -1247,13 +1228,13 @@ RowSelectionPlugin.prototype._selectFromAnchorToTarget = function (section, rowI
|
|
1247
1228
|
* @return {boolean}
|
1248
1229
|
*/
|
1249
1230
|
RowSelectionPlugin.prototype._gotoPrevGrid = function () {
|
1250
|
-
if
|
1231
|
+
if(!this._activeGrid) { return false; }
|
1251
1232
|
|
1252
|
-
if
|
1233
|
+
if(this._activeGrid === this._hosts[0]) { // This is the first grid
|
1253
1234
|
return false;
|
1254
1235
|
} else {
|
1255
|
-
|
1256
|
-
if
|
1236
|
+
let curIndex = this._hosts.indexOf(this._activeGrid);
|
1237
|
+
if(curIndex > 0) {
|
1257
1238
|
this._gotoGrid(curIndex - 1);
|
1258
1239
|
return true;
|
1259
1240
|
}
|
@@ -1264,14 +1245,14 @@ RowSelectionPlugin.prototype._gotoPrevGrid = function () {
|
|
1264
1245
|
* @return {boolean}
|
1265
1246
|
*/
|
1266
1247
|
RowSelectionPlugin.prototype._gotoNextGrid = function () {
|
1267
|
-
if
|
1248
|
+
if(!this._activeGrid) { return false; }
|
1268
1249
|
|
1269
|
-
|
1270
|
-
if
|
1250
|
+
let lastIndex = this._hosts.length - 1;
|
1251
|
+
if(this._activeGrid === this._hosts[lastIndex]) { // This is the last grid
|
1271
1252
|
return false;
|
1272
1253
|
} else {
|
1273
|
-
|
1274
|
-
if
|
1254
|
+
let curIndex = this._hosts.indexOf(this._activeGrid);
|
1255
|
+
if(curIndex >= 0) {
|
1275
1256
|
this._gotoGrid(curIndex + 1);
|
1276
1257
|
return true;
|
1277
1258
|
}
|
@@ -1282,8 +1263,8 @@ RowSelectionPlugin.prototype._gotoNextGrid = function () {
|
|
1282
1263
|
* @param {number} gridIndex
|
1283
1264
|
*/
|
1284
1265
|
RowSelectionPlugin.prototype._gotoGrid = function (gridIndex) {
|
1285
|
-
|
1286
|
-
|
1266
|
+
let anchorRow = this.getRowAnchor(this._anchorSection);
|
1267
|
+
let sectionIndex = this._anchorSection.getIndex();
|
1287
1268
|
this.clearSelectedRows(); // Clear all current grid's selections
|
1288
1269
|
this.selectSingleRow(anchorRow, sectionIndex, this._hosts[gridIndex]); // go to the next grid at the first column
|
1289
1270
|
if(this._activeGrid != null){
|
@@ -1295,8 +1276,8 @@ RowSelectionPlugin.prototype._gotoGrid = function (gridIndex) {
|
|
1295
1276
|
* @param {number} rowIndex
|
1296
1277
|
*/
|
1297
1278
|
RowSelectionPlugin.prototype._scrollToRow = function (rowIndex) {
|
1298
|
-
|
1299
|
-
if
|
1279
|
+
let host = this._hosts[0];
|
1280
|
+
if(host) {
|
1300
1281
|
host.scrollToRow(null, rowIndex);
|
1301
1282
|
}
|
1302
1283
|
};
|
@@ -1308,14 +1289,14 @@ RowSelectionPlugin.prototype._scrollToRow = function (rowIndex) {
|
|
1308
1289
|
* @return {boolean} return rather clients prefer cancel selection or not
|
1309
1290
|
*/
|
1310
1291
|
RowSelectionPlugin.prototype._dispatchBeforeSelection = function (e, ctx) {
|
1311
|
-
if
|
1312
|
-
if
|
1313
|
-
|
1292
|
+
if(this.hasListener("beforeSelection")) {
|
1293
|
+
if(!ctx) {
|
1294
|
+
let grid = this._activeGrid || this._hosts[0];
|
1314
1295
|
ctx = grid ? grid.getRelativePosition(e) : {};
|
1315
1296
|
}
|
1316
1297
|
ctx["event"] = e;
|
1317
1298
|
this._dispatch("beforeSelection", ctx); // Ask clients if they want to cancel this event
|
1318
|
-
if
|
1299
|
+
if(ctx["cancel"]) {
|
1319
1300
|
return true; // return true if clients want to cancel this event
|
1320
1301
|
}
|
1321
1302
|
}
|
@@ -1328,23 +1309,23 @@ RowSelectionPlugin.prototype._dispatchBeforeSelection = function (e, ctx) {
|
|
1328
1309
|
* @param {Object=} section ILayoutGrid
|
1329
1310
|
*/
|
1330
1311
|
RowSelectionPlugin.prototype._dispatchSelectionChanged = function (e, rowIndex, section) {
|
1331
|
-
if
|
1332
|
-
|
1333
|
-
if
|
1312
|
+
if(this._activeGrid) {
|
1313
|
+
let csp = this._getPlugin("ColumnSelectionPlugin");
|
1314
|
+
if(csp && csp["isEnabled"]()) {
|
1334
1315
|
csp["clearSelection"]();
|
1335
1316
|
}
|
1336
|
-
|
1337
|
-
if
|
1317
|
+
let cep = this._getPlugin("CellEditingPlugin");
|
1318
|
+
if(cep) {
|
1338
1319
|
cep.closeCellEditor();
|
1339
1320
|
}
|
1340
1321
|
cep = this._getPlugin("InCellEditingPlugin");
|
1341
|
-
if
|
1322
|
+
if(cep) {
|
1342
1323
|
cep.closeCellEditor();
|
1343
1324
|
}
|
1344
1325
|
}
|
1345
1326
|
|
1346
|
-
if
|
1347
|
-
|
1327
|
+
if(this.hasListener("selectionChanged")) {
|
1328
|
+
let obj = {};
|
1348
1329
|
obj["selectedRows"] = this.getSelectedRows();
|
1349
1330
|
obj["rowIndex"] = (rowIndex != null) ? rowIndex : this.getRowAnchor(this._anchorSection);
|
1350
1331
|
obj["section"] = (section != null) ? section : this._anchorSection;
|