@refinitiv-ui/efx-grid 6.0.94 → 6.0.95
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/grid/index.js +1 -1
- package/lib/tr-grid-checkbox/es6/Checkbox.js +1 -1
- package/lib/tr-grid-row-filtering/es6/RowFiltering.js +1537 -1425
- package/lib/types/es6/CoralButtonFormatter.d.ts +0 -2
- package/lib/types/es6/CoralIconFormatter.d.ts +0 -2
- package/lib/types/es6/CoralRadioButtonFormatter.d.ts +0 -2
- package/lib/types/es6/EFButtonFormatter.d.ts +0 -2
- package/lib/types/es6/EFIconFormatter.d.ts +0 -2
- package/lib/types/es6/EFRadioButtonFormatter.d.ts +0 -2
- package/lib/versions.json +2 -2
- package/package.json +1 -1
@@ -1,9 +1,8 @@
|
|
1
|
-
|
2
|
-
import {
|
3
|
-
import {
|
4
|
-
import {
|
5
|
-
import {
|
6
|
-
import { ElfUtil } from "../../tr-grid-util/es6/ElfUtil.js";
|
1
|
+
import {Ext} from "../../tr-grid-util/es6/Ext.js";
|
2
|
+
import {GridPlugin} from "../../tr-grid-util/es6/GridPlugin.js";
|
3
|
+
import {FilterBuilder, stringToDateObject} from "../../tr-grid-util/es6/FilterBuilder.js";
|
4
|
+
import {FilterOperators} from "../../tr-grid-util/es6/FilterOperators.js";
|
5
|
+
import {ElfUtil} from "../../tr-grid-util/es6/ElfUtil.js";
|
7
6
|
import { injectCss, prettifyCss, cloneObject } from "../../tr-grid-util/es6/Util.js";
|
8
7
|
|
9
8
|
/** @event RowFilteringPlugin#click
|
@@ -112,14 +111,14 @@ The expression can take various forms:<br>
|
|
112
111
|
* @param {Object} cfo
|
113
112
|
* @return {!RowFilteringPlugin~FilterExpression}
|
114
113
|
*/
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
114
|
+
let _toFilterExpression = function(cfo) {
|
115
|
+
let ctx = cfo._context[0];
|
116
|
+
// TODO: Handle rawDataAccessor and formattedDataAccessor (saving and loading of functions)
|
117
|
+
return {
|
118
|
+
field: cfo._field || "",
|
119
|
+
expression: cfo._expressions[0],
|
120
|
+
context: (ctx != null && !ctx._autoGenerated) ? ctx : null
|
121
|
+
};
|
123
122
|
};
|
124
123
|
/** @private
|
125
124
|
* @function
|
@@ -127,47 +126,53 @@ var _toFilterExpression = function _toFilterExpression(cfo) {
|
|
127
126
|
* @param {*} val
|
128
127
|
* @return {Array}
|
129
128
|
*/
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
129
|
+
let _arrayConcat = function(ary, val) {
|
130
|
+
if(Array.isArray(val) && val.length) {
|
131
|
+
if(ary) {
|
132
|
+
return ary.concat(val);
|
133
|
+
} else {
|
134
|
+
return val;
|
135
|
+
}
|
136
|
+
}
|
137
|
+
return ary;
|
139
138
|
};
|
140
139
|
|
141
140
|
/** @type {string}
|
142
141
|
* @private
|
143
142
|
* @const
|
144
143
|
*/
|
145
|
-
|
144
|
+
const BLANKS = "(Blanks)";
|
146
145
|
|
147
146
|
/** @constructor
|
148
147
|
* @extends {GridPlugin}
|
149
148
|
*/
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
149
|
+
let RowFilteringPlugin = function () {
|
150
|
+
let t = this;
|
151
|
+
|
152
|
+
t._onPreSectionRender = t._onPreSectionRender.bind(t);
|
153
|
+
t._onColumnAdded = t._onColumnAdded.bind(t);
|
154
|
+
t._onColumnRemoved = t._onColumnRemoved.bind(t);
|
155
|
+
t._onPreLoadedDialog = t._onPreLoadedDialog.bind(t);
|
156
|
+
|
157
|
+
t._onIconClicked = t._onIconClicked.bind(t);
|
158
|
+
t._filterLogic = t._filterLogic.bind(t);
|
159
|
+
t._updateAllColumnIcons = t._updateAllColumnIcons.bind(t);
|
160
|
+
t.refresh = t.refresh.bind(t);
|
161
|
+
t._requestFilterRefresh = t._requestFilterRefresh.bind(t);
|
162
|
+
|
163
|
+
|
164
|
+
t._globalFilters = [];
|
165
|
+
t._globalContexts = [];
|
166
|
+
t._columnFilters = [];
|
167
|
+
t._hosts = [];
|
168
|
+
t._dvs = [];
|
169
|
+
|
170
|
+
t._funcMap = {};
|
171
|
+
t._nameMap = {};
|
168
172
|
};
|
169
173
|
Ext.inherits(RowFilteringPlugin, GridPlugin);
|
170
174
|
|
175
|
+
|
171
176
|
/** @type {!Object.<string, Function>}
|
172
177
|
* @private
|
173
178
|
*/
|
@@ -257,245 +262,295 @@ RowFilteringPlugin._dialogTagName; // intentionally left undefined
|
|
257
262
|
*/
|
258
263
|
RowFilteringPlugin.prototype._dvs;
|
259
264
|
|
265
|
+
|
260
266
|
/** @public
|
261
267
|
* @return {string}
|
262
268
|
*/
|
263
269
|
RowFilteringPlugin.prototype.getName = function () {
|
264
|
-
|
270
|
+
return "RowFilteringPlugin"; // Read Only
|
265
271
|
};
|
266
272
|
/** @public
|
267
273
|
* @param {Object} host core grid instance
|
268
274
|
* @param {Object=} options
|
269
275
|
*/
|
270
276
|
RowFilteringPlugin.prototype.initialize = function (host, options) {
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
277
|
+
if(this._hosts.indexOf(host) >= 0) { return; }
|
278
|
+
this._hosts.push(host);
|
279
|
+
|
280
|
+
if(!RowFilteringPlugin._styles) {
|
281
|
+
RowFilteringPlugin._styles = prettifyCss([
|
282
|
+
".hovering-filter-icon .cell:not(.active-filter):hover .floating-panel .title-filter-icon", [
|
283
|
+
"display: flex;"
|
284
|
+
],
|
285
|
+
".hovering-filter-icon .cell:not(.active-filter) .floating-panel .title-filter-icon", [
|
286
|
+
"display: none;"
|
287
|
+
],
|
288
|
+
".floating-panel", [
|
289
|
+
"position:relative;"
|
290
|
+
],
|
291
|
+
".floating-panel .title-filter-icon", [
|
292
|
+
"color: var(--grid-title-filter-icon-color,inherit);"
|
293
|
+
],
|
294
|
+
".title .floating-panel .title-filter-icon:hover", [
|
295
|
+
"color: var(--grid-title-filter-icon-hover-color,inherit);"
|
296
|
+
],
|
297
|
+
".always-on-filter .floating-panel .title-filter-icon", [
|
298
|
+
"color: var(--grid-header-txtcolor,inherit);"
|
299
|
+
],
|
300
|
+
".always-on-filter .active-filter .floating-panel .title-filter-icon", [
|
301
|
+
"color: var(--grid-title-filter-icon-hover-color,inherit);"
|
302
|
+
],
|
303
|
+
".hovering-filter-icon .tiny-col .cell:hover, .tr-grid .tiny-col .cell.active-filter", [
|
304
|
+
"padding-left:0px;"
|
305
|
+
],
|
306
|
+
".tiny-col.movable .cell .floating-panel .title-filter-icon:before", [
|
307
|
+
"content: '.';",
|
308
|
+
"position: absolute;",
|
309
|
+
"margin-left: auto;",
|
310
|
+
"margin-right: auto;",
|
311
|
+
"left: 0;",
|
312
|
+
"right: 0;",
|
313
|
+
"top: -10px;",
|
314
|
+
"font-size: 10px;",
|
315
|
+
"font-family: monospace;",
|
316
|
+
"color: var(--grid-title-dot-icon,inherit);",
|
317
|
+
"text-align:center;"
|
318
|
+
]
|
319
|
+
]);
|
320
|
+
}
|
321
|
+
|
322
|
+
if(!host._rowFilteringStyles){
|
323
|
+
host._rowFilteringStyles = true;
|
324
|
+
injectCss(RowFilteringPlugin._styles, host.getElement());
|
325
|
+
}
|
326
|
+
|
327
|
+
|
328
|
+
host.unloadPlugin("ColumnFilterPlugin");
|
329
|
+
host.listen("preSectionRender", this._onPreSectionRender);
|
330
|
+
host.listen("postDataSourceChanged", this._requestFilterRefresh); // TODO: Check if this is necessary
|
331
|
+
host.listen("columnAdded", this._onColumnAdded);
|
332
|
+
host.listen("columnRemoved", this._onColumnRemoved);
|
333
|
+
|
334
|
+
this.config(options);
|
335
|
+
// In case of lazy loading
|
336
|
+
// TODO
|
290
337
|
};
|
291
338
|
/** @public
|
292
339
|
* @param {Object} host core grid instance
|
293
340
|
*/
|
294
341
|
RowFilteringPlugin.prototype.unload = function (host) {
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
342
|
+
let at = this._hosts.indexOf(host);
|
343
|
+
if(at < 0) { return; }
|
344
|
+
|
345
|
+
this._hosts.splice(at, 1);
|
346
|
+
|
347
|
+
host.unlisten("preSectionRender", this._onPreSectionRender);
|
348
|
+
host.unlisten("postDataSourceChanged", this._requestFilterRefresh);
|
349
|
+
host.unlisten("columnAdded", this._onColumnAdded);
|
350
|
+
host.unlisten("columnRemoved", this._onColumnRemoved);
|
351
|
+
|
352
|
+
if(!this._hosts.length) {
|
353
|
+
if(this._uiTimerId) {
|
354
|
+
clearTimeout(this._uiTimerId);
|
355
|
+
this._uiTimerId = 0;
|
356
|
+
}
|
357
|
+
if(this._filterTimerId) {
|
358
|
+
clearTimeout(this._filterTimerId);
|
359
|
+
this._filterTimerId = 0;
|
360
|
+
}
|
361
|
+
|
362
|
+
this._hasPendingFilter = false;
|
363
|
+
if(this._filterDialog) {
|
364
|
+
this._filterDialog.hide(); // Remove the dialog from document
|
365
|
+
this._filterDialog = null;
|
366
|
+
this._dialogInitialized = false;
|
367
|
+
}
|
368
|
+
}
|
369
|
+
|
370
|
+
this._dispose();
|
321
371
|
};
|
322
372
|
/**
|
323
373
|
* @protected
|
324
374
|
* @ignore
|
325
375
|
*/
|
326
|
-
RowFilteringPlugin.prototype._afterInit = function
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
376
|
+
RowFilteringPlugin.prototype._afterInit = function() {
|
377
|
+
if(!this._filterDialog) {
|
378
|
+
this._filterDialog = RowFilteringPlugin._createDialog();
|
379
|
+
this._dialogInitialized = false;
|
380
|
+
if(this._filterDialog) {
|
381
|
+
this._filterDialog.style.display = "none";
|
382
|
+
document.body.appendChild(this._filterDialog);
|
383
|
+
setTimeout(this._onPreLoadedDialog, 10);
|
384
|
+
}
|
385
|
+
}
|
386
|
+
this._applyPendingFilter();
|
337
387
|
};
|
338
388
|
|
339
389
|
/** @private
|
340
390
|
*/
|
341
|
-
RowFilteringPlugin.prototype._applyPendingFilter = function
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
391
|
+
RowFilteringPlugin.prototype._applyPendingFilter = function() {
|
392
|
+
if(!this._initializedGrid) {
|
393
|
+
return;
|
394
|
+
}
|
395
|
+
if(!this._hasPendingFilter) {
|
396
|
+
return;
|
397
|
+
}
|
398
|
+
|
399
|
+
this._hasPendingFilter = false;
|
400
|
+
let colCount = this.getColumnCount();
|
401
|
+
for(let c = 0; c < colCount; ++c) {
|
402
|
+
let colSettings = this._getUserColumnSettings(c);
|
403
|
+
if(colSettings.expression) {
|
404
|
+
this.addColumnFilter(c, colSettings.expression, colSettings.filterState);
|
405
|
+
} else {
|
406
|
+
this._removeColumnFilters(c);
|
407
|
+
}
|
408
|
+
}
|
358
409
|
};
|
359
410
|
/** @private
|
360
411
|
*/
|
361
|
-
RowFilteringPlugin.prototype._onPreLoadedDialog = function
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
412
|
+
RowFilteringPlugin.prototype._onPreLoadedDialog = function() {
|
413
|
+
if(this._filterDialog) {
|
414
|
+
this._filterDialog.style.display = "";
|
415
|
+
let pn = this._filterDialog.parentNode;
|
416
|
+
if(pn) {
|
417
|
+
pn.removeChild(this._filterDialog);
|
418
|
+
}
|
419
|
+
}
|
369
420
|
};
|
370
421
|
|
371
422
|
/** @public
|
372
423
|
* @param {Object=} options
|
373
424
|
*/
|
374
425
|
RowFilteringPlugin.prototype.config = function (options) {
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
426
|
+
if(!options) { return; }
|
427
|
+
|
428
|
+
let rowFiltering = options["rowFiltering"];
|
429
|
+
if(rowFiltering) {
|
430
|
+
if(rowFiltering["disabledUI"] || rowFiltering["uiDisabled"]) {
|
431
|
+
this._iconActivation = "none";
|
432
|
+
}
|
433
|
+
if(rowFiltering["emptySegmentFiltering"] != null) {
|
434
|
+
// TODO: there is a chance that there is no DataView during the configuration
|
435
|
+
this.enableEmptySegmentFiltering(rowFiltering["emptySegmentFiltering"] ? true : false);
|
436
|
+
}
|
437
|
+
if(rowFiltering["separatorFiltering"] != null) {
|
438
|
+
// TODO: there is a chance that there is no DataView during the configuration
|
439
|
+
this.enableSeparatorFiltering(rowFiltering["separatorFiltering"] ? true : false);
|
440
|
+
}
|
441
|
+
if(rowFiltering["iconActivation"]){
|
442
|
+
this._iconActivation = rowFiltering["iconActivation"];
|
443
|
+
|
444
|
+
for(let index = 0; index < this._hosts.length; index++){
|
445
|
+
if(this._iconActivation === "onHover"){
|
446
|
+
this._hosts[index].enableClass("hovering-filter-icon", true);
|
447
|
+
}else{
|
448
|
+
this._hosts[index].enableClass("hovering-filter-icon", false);
|
449
|
+
}
|
450
|
+
if(this._iconActivation === "always"){
|
451
|
+
this._hosts[index].enableClass("always-on-filter", true);
|
452
|
+
} else {
|
453
|
+
this._hosts[index].enableClass("always-on-filter", false);
|
454
|
+
}
|
455
|
+
}
|
456
|
+
}
|
457
|
+
if(rowFiltering["dialogOptions"]){
|
458
|
+
this._dialogOptions = rowFiltering["dialogOptions"];
|
459
|
+
}
|
460
|
+
if(rowFiltering["clicked"]) {
|
461
|
+
rowFiltering["click"] = rowFiltering["clicked"];
|
462
|
+
}
|
463
|
+
|
464
|
+
this.addListener(rowFiltering, "click");
|
465
|
+
this.addListener(rowFiltering, "beforeDialogOpened");
|
466
|
+
this.addListener(rowFiltering, "dialogCommitted");
|
467
|
+
this.addListener(rowFiltering, "iconCreated");
|
468
|
+
this.addListener(rowFiltering, "filterChanged");
|
469
|
+
this.addListener(rowFiltering, "refreshed");
|
470
|
+
}
|
471
|
+
|
472
|
+
let columns = options["columns"];
|
473
|
+
if(!columns) { return; }
|
474
|
+
|
475
|
+
// let host = this._hosts[0];
|
476
|
+
let len = columns.length;
|
477
|
+
for(let i = 0; i < len; ++i) {
|
478
|
+
let column = columns[i];
|
479
|
+
this._setColumnOptions(i, column);
|
480
|
+
}
|
481
|
+
this._applyPendingFilter();
|
431
482
|
};
|
432
483
|
/** @public
|
433
484
|
* @param {Object=} gridOptions
|
434
485
|
* @return {!Object}
|
435
486
|
*/
|
436
487
|
RowFilteringPlugin.prototype.getConfigObject = function (gridOptions) {
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
488
|
+
let obj = gridOptions || {};
|
489
|
+
|
490
|
+
let columns = obj.columns;
|
491
|
+
if(!columns) {
|
492
|
+
columns = obj.columns = [];
|
493
|
+
}
|
494
|
+
|
495
|
+
let len = this.getColumnCount();
|
496
|
+
for(let i = 0; i < len; ++i) {
|
497
|
+
let column = columns[i];
|
498
|
+
if(!column) {
|
499
|
+
column = columns[i] = {};
|
500
|
+
}
|
501
|
+
|
502
|
+
let colSettings = this._getUserColumnSettings(i);
|
503
|
+
let exp = colSettings.expression;
|
504
|
+
if(exp && typeof exp !== "function") { // TODO: Accept function type
|
505
|
+
if(typeof exp === "object" && !Array.isArray(exp)) {
|
506
|
+
let expClone = cloneObject(exp);
|
507
|
+
if(expClone[""] || expClone["null"] || expClone["undefined"] || expClone["NaN"]) {
|
508
|
+
delete expClone[""];
|
509
|
+
delete expClone["null"];
|
510
|
+
delete expClone["undefined"];
|
511
|
+
delete expClone["NaN"];
|
512
|
+
expClone[BLANKS] = true;
|
513
|
+
column.filter = expClone; // This could be only object
|
514
|
+
} else {
|
515
|
+
column.filter = exp;
|
516
|
+
}
|
517
|
+
} else {
|
518
|
+
column.filter = exp; // This could be string or array
|
519
|
+
}
|
520
|
+
}
|
521
|
+
let ctx = colSettings.filterState;
|
522
|
+
if(ctx != null) {
|
523
|
+
if(typeof ctx !== "object" || !ctx._autoGenerated) {
|
524
|
+
column.filterState = ctx;
|
525
|
+
}
|
526
|
+
}
|
527
|
+
|
528
|
+
let filterIcon = colSettings.filterIcon;
|
529
|
+
if(!filterIcon) {
|
530
|
+
column.filterIcon = false;
|
531
|
+
}
|
532
|
+
}
|
533
|
+
|
534
|
+
let extOptions = obj.rowFiltering;
|
535
|
+
let dirty = false;
|
536
|
+
if(!extOptions) {
|
537
|
+
extOptions = {};
|
538
|
+
}
|
539
|
+
if(this._iconActivation !== "onActiveFilter") {
|
540
|
+
extOptions.iconActivation = this._iconActivation;
|
541
|
+
dirty = true;
|
542
|
+
}
|
543
|
+
if(this._dialogOptions) {
|
544
|
+
extOptions.dialogOptions = this._dialogOptions; // TODO: dialogOptions should not contain any function
|
545
|
+
dirty = true;
|
546
|
+
}
|
547
|
+
// TODO: get emptySegmentFiltering setting from DataView
|
548
|
+
// TODO: get separatorFiltering setting from DataView
|
549
|
+
if(dirty) {
|
550
|
+
obj.rowFiltering = extOptions;
|
551
|
+
}
|
552
|
+
|
553
|
+
return obj;
|
499
554
|
};
|
500
555
|
|
501
556
|
/** All filter logics in DataView will be temporarily removed until re-enabling. This is useful when trying to insert an item at the specified index. After re-enabling, both logics and icons will be restored.
|
@@ -503,33 +558,32 @@ RowFilteringPlugin.prototype.getConfigObject = function (gridOptions) {
|
|
503
558
|
* @param {boolean=} opt_disabled
|
504
559
|
* @param {string=} opt_id For handling nested called
|
505
560
|
*/
|
506
|
-
RowFilteringPlugin.prototype.disable = function
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
}
|
561
|
+
RowFilteringPlugin.prototype.disable = function(opt_disabled, opt_id) {
|
562
|
+
let disabled = opt_disabled !== false;
|
563
|
+
if(!this._disablingIds) {
|
564
|
+
this._disablingIds = {};
|
565
|
+
}
|
566
|
+
if(!opt_id) { opt_id = "_"; }
|
567
|
+
this._disablingIds[opt_id] = disabled;
|
568
|
+
|
569
|
+
disabled = false;
|
570
|
+
for(let key in this._disablingIds) { // Find cumulative state
|
571
|
+
if(this._disablingIds[key]) {
|
572
|
+
disabled = true;
|
573
|
+
break;
|
574
|
+
}
|
575
|
+
}
|
576
|
+
|
577
|
+
if(this._disabled !== disabled) {
|
578
|
+
this._disabled = disabled;
|
579
|
+
if(disabled) {
|
580
|
+
this.refresh(); // Take an effect immediately
|
581
|
+
this._updateAllColumnIcons();
|
582
|
+
} else {
|
583
|
+
this._requestFilterRefresh(); // Take an effect later
|
584
|
+
this._setTimerForUpdatingIcons();
|
585
|
+
}
|
586
|
+
}
|
533
587
|
};
|
534
588
|
|
535
589
|
/** Add a global filter that is not related to any column. No filter icon is created in this way
|
@@ -540,30 +594,32 @@ RowFilteringPlugin.prototype.disable = function (opt_disabled, opt_id) {
|
|
540
594
|
* @return {string} If success, function name is returned, otherwise empty string
|
541
595
|
* @fires RowFilteringPlugin#filterChanged
|
542
596
|
*/
|
543
|
-
RowFilteringPlugin.prototype.addFilter = function
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
597
|
+
RowFilteringPlugin.prototype.addFilter = function(exp, funcName, ctx) {
|
598
|
+
let func = this._parseFilter(exp, -1);
|
599
|
+
if(!func) { return ""; }
|
600
|
+
|
601
|
+
if(!funcName) {
|
602
|
+
funcName = "_" + this._filterId++;
|
603
|
+
}
|
604
|
+
|
605
|
+
if(this._nameMap[funcName] || this._globalFilters.indexOf(func) >= 0) {
|
606
|
+
return ""; // Function is already exists
|
607
|
+
}
|
608
|
+
|
609
|
+
ctx = ctx != null ? ctx : null;
|
610
|
+
this._nameMap[funcName] = func;
|
611
|
+
this._globalFilters.push(func);
|
612
|
+
this._globalContexts.push(ctx);
|
613
|
+
|
614
|
+
this._dispatch("filterChanged", {
|
615
|
+
"filterType": "global",
|
616
|
+
"changeType": "add",
|
617
|
+
"colIndex": -1,
|
618
|
+
"field": null
|
619
|
+
});
|
620
|
+
|
621
|
+
this._requestFilterRefresh();
|
622
|
+
return funcName;
|
567
623
|
};
|
568
624
|
/** Add a global filter that is not related to any column. No filter icon is created in this way
|
569
625
|
* @public
|
@@ -572,8 +628,8 @@ RowFilteringPlugin.prototype.addFilter = function (exp, funcName, ctx) {
|
|
572
628
|
* @return {string} If success, function name is returned, otherwise empty string
|
573
629
|
* @fires RowFilteringPlugin#filterChanged
|
574
630
|
*/
|
575
|
-
RowFilteringPlugin.prototype.addGridFilter = function
|
576
|
-
|
631
|
+
RowFilteringPlugin.prototype.addGridFilter = function(exp, ctx) {
|
632
|
+
return this.addFilter(exp, null, ctx);
|
577
633
|
};
|
578
634
|
/** @private
|
579
635
|
* @param {RowFilteringPlugin~Expression} exp
|
@@ -581,40 +637,40 @@ RowFilteringPlugin.prototype.addGridFilter = function (exp, ctx) {
|
|
581
637
|
* @param {*=} ctx
|
582
638
|
* @return {Function}
|
583
639
|
*/
|
584
|
-
RowFilteringPlugin.prototype._parseFilter = function
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
640
|
+
RowFilteringPlugin.prototype._parseFilter = function(exp, colIndex, ctx) {
|
641
|
+
if(!exp) {
|
642
|
+
return null;
|
643
|
+
}
|
644
|
+
if(typeof exp === "function") {
|
645
|
+
return exp;
|
646
|
+
}
|
647
|
+
let filterBuilder = RowFilteringPlugin._getFilterBuilder();
|
648
|
+
let validIdx = (colIndex || colIndex === 0);
|
649
|
+
let field = validIdx ? this._getField(colIndex) : "";
|
650
|
+
let formatter = validIdx ? this._getFormatter(colIndex) : null;
|
651
|
+
|
652
|
+
let func = null;
|
653
|
+
if(typeof exp === "string") { // Free text does not need data accessors
|
654
|
+
func = this._funcMap[exp];
|
655
|
+
if(func == null) {
|
656
|
+
func = this._funcMap[exp] = filterBuilder.parse(exp, field, formatter, field);
|
657
|
+
}
|
658
|
+
} else {
|
659
|
+
let rawDataAccessor = null;
|
660
|
+
let formattedDataAccessor = null;
|
661
|
+
if(ctx) {
|
662
|
+
rawDataAccessor = ctx.rawDataAccessor || null;
|
663
|
+
formattedDataAccessor = ctx.formattedDataAccessor || null;
|
664
|
+
}
|
665
|
+
if(!Array.isArray(exp)) {
|
666
|
+
if(exp[BLANKS] || (ctx && ctx.blankValues)) {
|
667
|
+
exp[""] = exp["null"] = exp["undefined"] = exp["NaN"] = true;
|
668
|
+
delete exp[BLANKS];
|
669
|
+
}
|
670
|
+
}
|
671
|
+
func = filterBuilder.parse(exp, field, formatter, field, rawDataAccessor, formattedDataAccessor);
|
672
|
+
}
|
673
|
+
return func;
|
618
674
|
};
|
619
675
|
/** If you want the column to always have one single filter, please use {@link RowFilteringPlugin#setColumnFilter} instead. This method allow a single column to have multiple filters.
|
620
676
|
* @public
|
@@ -624,60 +680,65 @@ RowFilteringPlugin.prototype._parseFilter = function (exp, colIndex, ctx) {
|
|
624
680
|
* @return {boolean} True if success
|
625
681
|
* @fires RowFilteringPlugin#filterChanged
|
626
682
|
*/
|
627
|
-
RowFilteringPlugin.prototype.addColumnFilter = function
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
683
|
+
RowFilteringPlugin.prototype.addColumnFilter = function(colIndex, exp, ctx) {
|
684
|
+
if(colIndex < 0 || colIndex >= this.getColumnCount()) {
|
685
|
+
return false;
|
686
|
+
}
|
687
|
+
|
688
|
+
let cfo = this._getColumnFilterOption(colIndex);
|
689
|
+
if(cfo) {
|
690
|
+
if(cfo._expressions[0] === exp) {
|
691
|
+
return false; // The same expression is getting added on the same column twice
|
692
|
+
}
|
693
|
+
}
|
694
|
+
|
695
|
+
let func = null;
|
696
|
+
if(typeof exp === "function") {
|
697
|
+
func = /** @type{Function} */(exp);
|
698
|
+
if(ctx && typeof ctx === "string") {
|
699
|
+
exp = ctx;
|
700
|
+
}
|
701
|
+
} else {
|
702
|
+
func = this._parseFilter(exp, colIndex, ctx);
|
703
|
+
}
|
704
|
+
|
705
|
+
if(!func) {
|
706
|
+
return false;
|
707
|
+
}
|
708
|
+
|
709
|
+
let colSettings = this._getUserColumnSettings(colIndex);
|
710
|
+
colSettings.expression = exp; // WARNING: Only the last expression are saved (previous one is overwritten)
|
711
|
+
colSettings.filterState = ctx;
|
712
|
+
|
713
|
+
if(ctx == null) {
|
714
|
+
ctx = {"_autoGenerated": true};
|
715
|
+
}
|
716
|
+
|
717
|
+
let field = this._getField(colIndex);
|
718
|
+
if(ctx && typeof ctx === "object") {
|
719
|
+
ctx["field"] = field;
|
720
|
+
}
|
721
|
+
|
722
|
+
cfo = this._initColumnFilterOption(colIndex);
|
723
|
+
cfo._field = field; // TODO: Handle fieldDataType
|
724
|
+
cfo._filters.push(func);
|
725
|
+
cfo._expressions.push(exp);
|
726
|
+
cfo._context.push(ctx);
|
727
|
+
cfo._rawDataAccessor = ctx.rawDataAccessor || null;
|
728
|
+
cfo._formattedDataAccessor = ctx.formattedDataAccessor || null;
|
729
|
+
this._columnFilters.push(cfo);
|
730
|
+
|
731
|
+
this._dispatch("filterChanged", {
|
732
|
+
"filterType": "column",
|
733
|
+
"changeType": "add",
|
734
|
+
"colIndex": colIndex,
|
735
|
+
"field": field
|
736
|
+
});
|
737
|
+
|
738
|
+
// UI
|
739
|
+
this._requestFilterRefresh();
|
740
|
+
this._updateColumnIcon(colIndex);
|
741
|
+
return true;
|
681
742
|
};
|
682
743
|
/** This method guarantees that the column can have at most one filter at the time. It performs {@link RowFilteringPlugin#removeColumnFilters} before {@link RowFilteringPlugin#addColumnFilter}
|
683
744
|
* @public
|
@@ -699,25 +760,27 @@ RowFilteringPlugin.prototype.addColumnFilter = function (colIndex, exp, ctx) {
|
|
699
760
|
* }
|
700
761
|
* );
|
701
762
|
*/
|
702
|
-
RowFilteringPlugin.prototype.setColumnFilter = function
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
763
|
+
RowFilteringPlugin.prototype.setColumnFilter = function(colIndex, exp, ctx) {
|
764
|
+
let curExp = this.getColumnFilterExpression(colIndex);
|
765
|
+
if(curExp === exp) {
|
766
|
+
return false;
|
767
|
+
}
|
768
|
+
|
769
|
+
let removed = this._removeColumnFilters(colIndex);
|
770
|
+
|
771
|
+
let added = this.addColumnFilter(colIndex, exp, ctx);
|
772
|
+
if(!added && removed) {
|
773
|
+
this._updateColumnIcon(colIndex);
|
774
|
+
}
|
775
|
+
return removed || added;
|
713
776
|
};
|
714
777
|
/** @public
|
715
778
|
* @param {number} colIndex
|
716
779
|
* @return {RowFilteringPlugin~Expression}
|
717
780
|
*/
|
718
|
-
RowFilteringPlugin.prototype.getColumnFilterExpression = function
|
719
|
-
|
720
|
-
|
781
|
+
RowFilteringPlugin.prototype.getColumnFilterExpression = function(colIndex) {
|
782
|
+
let colSettings = this._getUserColumnSettings(colIndex);
|
783
|
+
return colSettings.expression || null;
|
721
784
|
};
|
722
785
|
/** Set data to colData["rowFiltering"]
|
723
786
|
* @private
|
@@ -738,95 +801,96 @@ RowFilteringPlugin.prototype.getColumnFilterExpression = function (colIndex) {
|
|
738
801
|
* }
|
739
802
|
* };
|
740
803
|
*/
|
741
|
-
RowFilteringPlugin.prototype._setColumnOptions = function
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
-
|
759
|
-
|
760
|
-
|
761
|
-
|
762
|
-
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
|
768
|
-
|
804
|
+
RowFilteringPlugin.prototype._setColumnOptions = function(colIndex, userObj) {
|
805
|
+
let colSettings = this._getUserColumnSettings(colIndex);
|
806
|
+
let filterIcon = userObj["filterIcon"];
|
807
|
+
|
808
|
+
// TODO: This should not be set here, should retreive data type from Composite/Realtime Grid
|
809
|
+
let fieldDataType = userObj["fieldDataType"] || userObj["dataType"];
|
810
|
+
if(fieldDataType) {
|
811
|
+
colSettings.fieldDataType = fieldDataType; // TODO: This should not be set here, should retreive data type from Composite/Realtime Grid
|
812
|
+
}
|
813
|
+
if(filterIcon != null) {
|
814
|
+
colSettings.filterIcon = filterIcon;
|
815
|
+
}
|
816
|
+
let exp = userObj["filter"];
|
817
|
+
if(exp != null) {
|
818
|
+
colSettings.expression = exp;
|
819
|
+
colSettings.filterState = null;
|
820
|
+
this._hasPendingFilter = true;
|
821
|
+
}
|
822
|
+
let filterState = userObj["filterState"];
|
823
|
+
if(filterState != null) {
|
824
|
+
colSettings.filterState = filterState;
|
825
|
+
}
|
826
|
+
|
827
|
+
let iconActivation = filterIcon == false ? "none" : this._iconActivation;
|
828
|
+
if(iconActivation == "always" || iconActivation == "onHover") {
|
829
|
+
this._updateColumnIcon(colIndex);
|
830
|
+
}
|
831
|
+
|
832
|
+
return (exp != null);
|
769
833
|
};
|
770
834
|
/** @private
|
771
835
|
* @param {number} colIndex
|
772
836
|
* @return {!Object} colData["rowFiltering"]
|
773
837
|
*/
|
774
|
-
RowFilteringPlugin.prototype._getUserColumnSettings = function
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
|
780
|
-
|
838
|
+
RowFilteringPlugin.prototype._getUserColumnSettings = function(colIndex) {
|
839
|
+
let colData = this._newColumnData(colIndex);
|
840
|
+
let colSettings = colData["rowFiltering"];
|
841
|
+
if(!colSettings) {
|
842
|
+
colSettings = colData["rowFiltering"] = {};
|
843
|
+
}
|
844
|
+
return colSettings;
|
781
845
|
};
|
782
846
|
/** @private
|
783
847
|
* @param {number} colIndex
|
784
848
|
* @return {Object} colData["rowFiltering"]["filterOption"]
|
785
849
|
*/
|
786
|
-
RowFilteringPlugin.prototype._getColumnFilterOption = function
|
787
|
-
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
|
792
|
-
|
850
|
+
RowFilteringPlugin.prototype._getColumnFilterOption = function(colIndex) {
|
851
|
+
let colSettings = this._getUserColumnSettings(colIndex);
|
852
|
+
if(colSettings) {
|
853
|
+
return colSettings["filterOption"] || null;
|
854
|
+
} else {
|
855
|
+
return null;
|
856
|
+
}
|
793
857
|
};
|
794
858
|
/** Remove colData["rowFiltering"]["filterOption"]
|
795
859
|
* @private
|
796
860
|
* @param {number} colIndex
|
797
861
|
*/
|
798
|
-
RowFilteringPlugin.prototype._removeActiveFilterStates = function
|
799
|
-
|
800
|
-
|
801
|
-
|
802
|
-
|
803
|
-
|
804
|
-
|
805
|
-
|
806
|
-
|
807
|
-
|
808
|
-
|
809
|
-
|
810
|
-
|
811
|
-
|
812
|
-
|
813
|
-
|
862
|
+
RowFilteringPlugin.prototype._removeActiveFilterStates = function(colIndex) {
|
863
|
+
let colSettings = this._getUserColumnSettings(colIndex);
|
864
|
+
colSettings.expression = null;
|
865
|
+
colSettings.filterState = null;
|
866
|
+
let cfo = colSettings["filterOption"];
|
867
|
+
if(cfo) {
|
868
|
+
colSettings["filterOption"] = null;
|
869
|
+
if(cfo._filters.length) {
|
870
|
+
this._dispatch("filterChanged", {
|
871
|
+
"filterType": "column",
|
872
|
+
"changeType": "remove",
|
873
|
+
"colIndex": colIndex,
|
874
|
+
"field": this._getField(colIndex)
|
875
|
+
});
|
876
|
+
}
|
877
|
+
}
|
814
878
|
};
|
815
879
|
/** @private
|
816
880
|
* @param {number} colIndex
|
817
881
|
* @return {!Object}
|
818
882
|
*/
|
819
|
-
RowFilteringPlugin.prototype._initColumnFilterOption = function
|
820
|
-
|
821
|
-
|
822
|
-
|
823
|
-
|
824
|
-
|
825
|
-
|
826
|
-
|
827
|
-
|
828
|
-
|
829
|
-
|
883
|
+
RowFilteringPlugin.prototype._initColumnFilterOption = function(colIndex) {
|
884
|
+
let cfo = this._getColumnFilterOption(colIndex);
|
885
|
+
if(!cfo) {
|
886
|
+
cfo = {};
|
887
|
+
cfo._filters = [];
|
888
|
+
cfo._expressions = [];
|
889
|
+
cfo._context = [];
|
890
|
+
let colSettings = this._getUserColumnSettings(colIndex);
|
891
|
+
colSettings["filterOption"] = cfo;
|
892
|
+
}
|
893
|
+
return cfo;
|
830
894
|
};
|
831
895
|
|
832
896
|
/** Remove the registered global filter. The column filter cannot be removed
|
@@ -834,33 +898,32 @@ RowFilteringPlugin.prototype._initColumnFilterOption = function (colIndex) {
|
|
834
898
|
* @param {Function|string} funcRef Function object or the function name can be used to remove
|
835
899
|
* @return {boolean} True if success
|
836
900
|
*/
|
837
|
-
RowFilteringPlugin.prototype.removeFilter = function
|
838
|
-
|
839
|
-
|
840
|
-
|
841
|
-
|
842
|
-
|
843
|
-
|
844
|
-
|
845
|
-
|
846
|
-
|
847
|
-
|
848
|
-
|
849
|
-
|
850
|
-
|
851
|
-
|
852
|
-
|
853
|
-
|
854
|
-
|
855
|
-
|
856
|
-
|
857
|
-
|
858
|
-
|
859
|
-
|
860
|
-
|
861
|
-
|
862
|
-
|
863
|
-
return true;
|
901
|
+
RowFilteringPlugin.prototype.removeFilter = function(funcRef) {
|
902
|
+
let func = null;
|
903
|
+
let funcName = "";
|
904
|
+
let funcIndex = -1;
|
905
|
+
if(typeof funcRef === "string") {
|
906
|
+
funcName = /** @type{string} */(funcRef);
|
907
|
+
func = this._nameMap[funcRef];
|
908
|
+
funcIndex = this._globalFilters.indexOf(func);
|
909
|
+
} else {
|
910
|
+
func = /** @type{Function} */(funcRef);
|
911
|
+
funcIndex = this._globalFilters.indexOf(func);
|
912
|
+
if(funcIndex >= 0) {
|
913
|
+
for(let key in this._nameMap) {
|
914
|
+
if(this._nameMap[key] === func) {
|
915
|
+
funcName = key;
|
916
|
+
}
|
917
|
+
}
|
918
|
+
}
|
919
|
+
}
|
920
|
+
if(funcIndex < 0) { return false; }
|
921
|
+
|
922
|
+
delete this._nameMap[funcName];
|
923
|
+
this._globalFilters.splice(funcIndex, 1);
|
924
|
+
this._globalContexts.splice(funcIndex, 1);
|
925
|
+
this._requestFilterRefresh();
|
926
|
+
return true;
|
864
927
|
};
|
865
928
|
/** Remove all filters in from the specified column
|
866
929
|
* @public
|
@@ -868,35 +931,35 @@ RowFilteringPlugin.prototype.removeFilter = function (funcRef) {
|
|
868
931
|
* @return {boolean} True if there is any change
|
869
932
|
* @fires RowFilteringPlugin#filterChanged
|
870
933
|
*/
|
871
|
-
RowFilteringPlugin.prototype.removeColumnFilters = function
|
872
|
-
|
873
|
-
|
874
|
-
|
875
|
-
|
876
|
-
|
877
|
-
|
878
|
-
|
879
|
-
|
880
|
-
|
934
|
+
RowFilteringPlugin.prototype.removeColumnFilters = function(colIndex) {
|
935
|
+
if(colIndex == null) { // Prevent user mistake
|
936
|
+
return this.removeAllColumnFilters();
|
937
|
+
}
|
938
|
+
|
939
|
+
let dirty = this._removeColumnFilters(colIndex);
|
940
|
+
if(dirty) {
|
941
|
+
this._updateColumnIcon(colIndex);
|
942
|
+
}
|
943
|
+
return dirty;
|
881
944
|
};
|
882
945
|
/** @private
|
883
946
|
* @param {number} colIndex
|
884
947
|
* @return {boolean} True if there is any change
|
885
948
|
* @fires RowFilteringPlugin#filterChanged
|
886
949
|
*/
|
887
|
-
RowFilteringPlugin.prototype._removeColumnFilters = function
|
888
|
-
|
889
|
-
|
890
|
-
|
891
|
-
|
892
|
-
|
893
|
-
|
894
|
-
|
895
|
-
|
896
|
-
|
897
|
-
|
898
|
-
|
899
|
-
|
950
|
+
RowFilteringPlugin.prototype._removeColumnFilters = function(colIndex) {
|
951
|
+
let cfo = this._getColumnFilterOption(colIndex);
|
952
|
+
if(cfo) {
|
953
|
+
let funcIndex = this._columnFilters.indexOf(cfo);
|
954
|
+
if(funcIndex >= 0) {
|
955
|
+
this._columnFilters.splice(funcIndex, 1);
|
956
|
+
}
|
957
|
+
this._removeActiveFilterStates(colIndex); // filterChanged fired
|
958
|
+
let inputExt = this._getPlugin("FilterInputPlugin"); // TODO: Use the event instead
|
959
|
+
inputExt && inputExt.updateUI(colIndex, "");
|
960
|
+
this._requestFilterRefresh();
|
961
|
+
}
|
962
|
+
return cfo ? true : false;
|
900
963
|
};
|
901
964
|
/** Alias to {@link RowFilteringPlugin#removeColumnFilters} Remove all filters from the specified column
|
902
965
|
* @public
|
@@ -912,155 +975,159 @@ RowFilteringPlugin.prototype.removeColumnFilter = RowFilteringPlugin.prototype.r
|
|
912
975
|
* @return {boolean} Return true if there is any change
|
913
976
|
* @fires RowFilteringPlugin#filterChanged
|
914
977
|
*/
|
915
|
-
RowFilteringPlugin.prototype.removeAllColumnFilters = function
|
916
|
-
|
917
|
-
|
918
|
-
|
919
|
-
|
920
|
-
|
921
|
-
|
922
|
-
|
923
|
-
|
924
|
-
|
925
|
-
|
926
|
-
|
927
|
-
|
928
|
-
|
929
|
-
|
978
|
+
RowFilteringPlugin.prototype.removeAllColumnFilters = function() {
|
979
|
+
if(this._columnFilters.length) {
|
980
|
+
this._columnFilters.length = 0;
|
981
|
+
|
982
|
+
let inputExt = this._getPlugin("FilterInputPlugin");
|
983
|
+
let colCount = this._getColumnCount();
|
984
|
+
for(let i = 0; i < colCount; ++i) {
|
985
|
+
this._removeActiveFilterStates(i); // filterChanged fired
|
986
|
+
inputExt && inputExt.updateUI(i, ""); // TODO: Use the event instead
|
987
|
+
}
|
988
|
+
|
989
|
+
this._updateAllColumnIcons();
|
990
|
+
|
991
|
+
this._requestFilterRefresh();
|
992
|
+
return true;
|
993
|
+
}
|
994
|
+
return false;
|
930
995
|
};
|
931
996
|
/** Remove all column and global filters. OverridingFilters are not removed by this method
|
932
997
|
* @public
|
933
998
|
*/
|
934
|
-
RowFilteringPlugin.prototype.removeAllFilters = function
|
935
|
-
|
936
|
-
|
937
|
-
|
938
|
-
|
939
|
-
|
940
|
-
|
941
|
-
|
942
|
-
|
943
|
-
|
944
|
-
|
945
|
-
|
946
|
-
|
947
|
-
|
948
|
-
|
949
|
-
|
950
|
-
|
999
|
+
RowFilteringPlugin.prototype.removeAllFilters = function() {
|
1000
|
+
let totalFilter = this._globalFilters.length + this._columnFilters.length;
|
1001
|
+
if(totalFilter <= 0) { return; }
|
1002
|
+
if(this._globalFilters.length) {
|
1003
|
+
this._globalFilters.length = 0;
|
1004
|
+
this._nameMap = {};
|
1005
|
+
|
1006
|
+
this._dispatch("filterChanged", {
|
1007
|
+
"filterType": "global",
|
1008
|
+
"changeType": "remove",
|
1009
|
+
"colIndex": -1,
|
1010
|
+
"field": ""
|
1011
|
+
});
|
1012
|
+
}
|
1013
|
+
|
1014
|
+
this.removeAllColumnFilters();
|
1015
|
+
|
1016
|
+
this._requestFilterRefresh();
|
951
1017
|
};
|
952
1018
|
|
953
1019
|
/** Column overriding function is processed before column filters and after global filters. If it returns non-zero, the result will override all other column filter results. If it returns 1, the row will be always included. If it returns -1, the row will be always excluded. If it returns 0, the column filters will be used as normal.
|
954
1020
|
* @public
|
955
1021
|
* @param {Function} func
|
956
1022
|
*/
|
957
|
-
RowFilteringPlugin.prototype.setOverridingFilter = function
|
958
|
-
|
1023
|
+
RowFilteringPlugin.prototype.setOverridingFilter = function(func) {
|
1024
|
+
this._overridingFilter = func;
|
959
1025
|
};
|
960
1026
|
/** PreTransform is used to minimize the same data transformation on multiple filters. Output from the given method will be used on all subsequent filters. Note that it will be used for every existing row, so performance should be critical in here. This is optional setting.
|
961
1027
|
* @public
|
962
1028
|
* @param {Function} func This function must return object with key and value pairs
|
963
1029
|
*/
|
964
|
-
RowFilteringPlugin.prototype.setPreTransform = function
|
965
|
-
|
1030
|
+
RowFilteringPlugin.prototype.setPreTransform = function(func) {
|
1031
|
+
this._preTransform = func;
|
966
1032
|
};
|
967
1033
|
/** This is the same as preTransform, only it is executed just before column filters and after the global filters. This is optional setting.
|
968
1034
|
* @public
|
969
1035
|
* @param {Function} func This function must return object with key and value pairs
|
970
1036
|
*/
|
971
|
-
RowFilteringPlugin.prototype.setRowTransform = function
|
972
|
-
|
1037
|
+
RowFilteringPlugin.prototype.setRowTransform = function(func) {
|
1038
|
+
this._rowTransform = func;
|
973
1039
|
};
|
974
1040
|
|
975
1041
|
/** @public
|
976
1042
|
* @return {!Array.<Function>} All global filters
|
977
1043
|
*/
|
978
|
-
RowFilteringPlugin.prototype.getFilters = function
|
979
|
-
|
1044
|
+
RowFilteringPlugin.prototype.getFilters = function() {
|
1045
|
+
return this._globalFilters;
|
980
1046
|
};
|
981
1047
|
/** Returns filter functions. Use getConfigObject for saving and loading instead of this function
|
982
1048
|
* @public
|
983
1049
|
* @return {!Array.<Function>} All column filters
|
984
1050
|
* @see {@link RowFilteringPlugin.getConfigObject}
|
985
1051
|
*/
|
986
|
-
RowFilteringPlugin.prototype.getAllColumnFilters = function
|
987
|
-
|
988
|
-
|
989
|
-
|
990
|
-
|
991
|
-
|
992
|
-
|
993
|
-
|
994
|
-
|
995
|
-
|
996
|
-
|
1052
|
+
RowFilteringPlugin.prototype.getAllColumnFilters = function() {
|
1053
|
+
let filters = [];
|
1054
|
+
let len = this._columnFilters.length;
|
1055
|
+
for(let i = 0; i < len; ++i) {
|
1056
|
+
let cfo = this._columnFilters[i];
|
1057
|
+
let jLen = cfo._filters.length;
|
1058
|
+
for(let j = 0; j < jLen; ++j) {
|
1059
|
+
filters.push(cfo._filters[j]);
|
1060
|
+
}
|
1061
|
+
}
|
1062
|
+
return filters;
|
997
1063
|
};
|
998
1064
|
/** Deprecated in favor of getConfigObject(). Get existing filter expressions for saving and restoring.
|
999
1065
|
* @public
|
1000
1066
|
* @return {Array.<RowFilteringPlugin~FilterExpression>} Return null if there is no column filter
|
1001
1067
|
* @see {@link RowFilteringPlugin.getConfigObject}
|
1002
1068
|
*/
|
1003
|
-
RowFilteringPlugin.prototype.getFilterExpressions = function
|
1004
|
-
|
1005
|
-
|
1006
|
-
|
1007
|
-
|
1008
|
-
|
1069
|
+
RowFilteringPlugin.prototype.getFilterExpressions = function() {
|
1070
|
+
if(this._columnFilters.length) {
|
1071
|
+
// TODO: Provide a way to save rawDataAccessor and formattedDataAccessor
|
1072
|
+
return this._columnFilters.map(_toFilterExpression);
|
1073
|
+
}
|
1074
|
+
return null;
|
1009
1075
|
};
|
1010
1076
|
/** Deprecated. Clear all existing column filters and restore column filters from the given valid filter expressions. If the parameter is null, the result is equivalent to calling removeAllColumnFilters();
|
1011
1077
|
* @public
|
1012
1078
|
* @param {Array.<RowFilteringPlugin~FilterExpression>} filterExps
|
1013
1079
|
*/
|
1014
|
-
RowFilteringPlugin.prototype.setFilterExpressions = function
|
1015
|
-
|
1016
|
-
|
1017
|
-
|
1018
|
-
|
1019
|
-
|
1020
|
-
|
1021
|
-
|
1022
|
-
|
1023
|
-
|
1024
|
-
|
1025
|
-
|
1026
|
-
|
1027
|
-
|
1028
|
-
|
1080
|
+
RowFilteringPlugin.prototype.setFilterExpressions = function(filterExps) {
|
1081
|
+
this.removeAllColumnFilters();
|
1082
|
+
|
1083
|
+
if(Array.isArray(filterExps)) {
|
1084
|
+
let api = this.getGridApi();
|
1085
|
+
let fields = api.getColumnFields();
|
1086
|
+
let len = filterExps.length;
|
1087
|
+
for(let i = 0; i < len; ++i) {
|
1088
|
+
let filterExp = filterExps[i];
|
1089
|
+
let field = filterExp.field;
|
1090
|
+
let colIndex = fields.indexOf(field);
|
1091
|
+
if(colIndex >= 0) {
|
1092
|
+
this.setColumnFilter(colIndex, filterExp.expression, filterExp.context);
|
1093
|
+
}
|
1094
|
+
}
|
1095
|
+
}
|
1029
1096
|
};
|
1030
1097
|
|
1031
1098
|
/** @public
|
1032
1099
|
* @return {boolean}
|
1033
1100
|
*/
|
1034
|
-
RowFilteringPlugin.prototype.hasColumnFilter = function
|
1035
|
-
|
1101
|
+
RowFilteringPlugin.prototype.hasColumnFilter = function() {
|
1102
|
+
return (this._columnFilters.length > 0);
|
1036
1103
|
};
|
1037
1104
|
/** @public
|
1038
1105
|
* @param {number} colIndex
|
1039
1106
|
* @return {Array.<Element>} icons
|
1040
1107
|
*/
|
1041
|
-
RowFilteringPlugin.prototype.getColumnFilterIcons = function
|
1042
|
-
|
1043
|
-
|
1044
|
-
|
1045
|
-
|
1046
|
-
|
1047
|
-
|
1048
|
-
|
1049
|
-
|
1050
|
-
|
1051
|
-
|
1052
|
-
|
1053
|
-
|
1054
|
-
|
1055
|
-
|
1108
|
+
RowFilteringPlugin.prototype.getColumnFilterIcons = function(colIndex) {
|
1109
|
+
let icons = [];
|
1110
|
+
for(let i = this._hosts.length; --i >= 0;) {
|
1111
|
+
let host = this._hosts[i];
|
1112
|
+
let tsect = host.getSection("title");
|
1113
|
+
if(!tsect) {
|
1114
|
+
continue;
|
1115
|
+
}
|
1116
|
+
let rCount = tsect.getRowCount();
|
1117
|
+
let cell = tsect.getCell(colIndex, rCount - 1, true); // Get bottom cell
|
1118
|
+
if(cell && cell._filterIcon) {
|
1119
|
+
icons.push(cell._filterIcon);
|
1120
|
+
}
|
1121
|
+
}
|
1122
|
+
return icons;
|
1056
1123
|
};
|
1057
1124
|
/** @public */
|
1058
|
-
RowFilteringPlugin.prototype.updateAllColumnIcons = function
|
1059
|
-
|
1060
|
-
|
1061
|
-
|
1062
|
-
|
1063
|
-
|
1125
|
+
RowFilteringPlugin.prototype.updateAllColumnIcons = function() {
|
1126
|
+
if(this._uiTimerId) {
|
1127
|
+
clearTimeout(this._uiTimerId);
|
1128
|
+
this._uiTimerId = 0;
|
1129
|
+
}
|
1130
|
+
this._updateAllColumnIcons();
|
1064
1131
|
};
|
1065
1132
|
|
1066
1133
|
/** Specify a list of data views to be filtered, excluding default data views used by UI. <br>
|
@@ -1068,105 +1135,114 @@ RowFilteringPlugin.prototype.updateAllColumnIcons = function () {
|
|
1068
1135
|
* @public
|
1069
1136
|
* @param {Object} dv DataView
|
1070
1137
|
*/
|
1071
|
-
RowFilteringPlugin.prototype.addDataView = function
|
1072
|
-
|
1073
|
-
|
1074
|
-
|
1075
|
-
|
1076
|
-
|
1138
|
+
RowFilteringPlugin.prototype.addDataView = function(dv) {
|
1139
|
+
let at = this._dvs.indexOf(dv);
|
1140
|
+
if(at < 0) {
|
1141
|
+
this._dvs.push(dv);
|
1142
|
+
this._requestFilterRefresh();
|
1143
|
+
}
|
1077
1144
|
};
|
1078
1145
|
/** @public
|
1079
1146
|
* @param {Object} dv DataView
|
1080
1147
|
*/
|
1081
|
-
RowFilteringPlugin.prototype.removeDataView = function
|
1082
|
-
|
1083
|
-
|
1084
|
-
|
1085
|
-
|
1086
|
-
|
1148
|
+
RowFilteringPlugin.prototype.removeDataView = function(dv) {
|
1149
|
+
let at = this._dvs.indexOf(dv);
|
1150
|
+
if(at >= 0) {
|
1151
|
+
this._dvs.splice(at, 1);
|
1152
|
+
this._requestFilterRefresh(); // This could be unnecessary
|
1153
|
+
}
|
1087
1154
|
};
|
1088
1155
|
|
1156
|
+
|
1089
1157
|
/** @private
|
1090
1158
|
* @param {Object} e
|
1091
1159
|
*/
|
1092
1160
|
RowFilteringPlugin.prototype._onPreSectionRender = function (e) {
|
1093
|
-
|
1094
|
-
|
1095
|
-
|
1096
|
-
this._setTimerForUpdatingIcons();
|
1161
|
+
if(e["sectionType"] !== "title") { return; }
|
1162
|
+
|
1163
|
+
this._setTimerForUpdatingIcons();
|
1097
1164
|
};
|
1098
1165
|
/** @private
|
1099
1166
|
* @param {Event} e
|
1100
1167
|
*/
|
1101
|
-
RowFilteringPlugin.prototype._onIconClicked = function
|
1102
|
-
|
1103
|
-
|
1104
|
-
|
1105
|
-
|
1106
|
-
|
1107
|
-
|
1108
|
-
|
1109
|
-
|
1110
|
-
|
1168
|
+
RowFilteringPlugin.prototype._onIconClicked = function(e) {
|
1169
|
+
let host = this._hosts[0];
|
1170
|
+
if(!host) { return; }
|
1171
|
+
|
1172
|
+
let pos = host.getRelativePosition(e);
|
1173
|
+
this.openDialog(pos.colIndex);
|
1174
|
+
|
1175
|
+
e.stopPropagation();
|
1176
|
+
e.preventDefault();
|
1177
|
+
this._dispatch("click", e);
|
1111
1178
|
};
|
1112
1179
|
/** @private
|
1113
1180
|
* @param {string} rid
|
1114
1181
|
* @param {Object} rowData
|
1115
1182
|
* @return {boolean}
|
1116
1183
|
*/
|
1117
|
-
RowFilteringPlugin.prototype._filterLogic = function
|
1118
|
-
|
1119
|
-
|
1120
|
-
|
1121
|
-
|
1122
|
-
|
1123
|
-
|
1124
|
-
|
1125
|
-
|
1126
|
-
|
1127
|
-
|
1128
|
-
|
1129
|
-
|
1130
|
-
|
1131
|
-
|
1132
|
-
|
1133
|
-
|
1134
|
-
|
1135
|
-
|
1136
|
-
|
1137
|
-
|
1138
|
-
|
1139
|
-
|
1140
|
-
|
1141
|
-
|
1142
|
-
|
1143
|
-
|
1144
|
-
|
1145
|
-
|
1146
|
-
|
1147
|
-
|
1148
|
-
|
1149
|
-
|
1150
|
-
|
1151
|
-
|
1152
|
-
|
1153
|
-
|
1154
|
-
|
1184
|
+
RowFilteringPlugin.prototype._filterLogic = function(rid, rowData) {
|
1185
|
+
if(rowData) {
|
1186
|
+
if(this._rowGetter) {
|
1187
|
+
rowData = this._rowGetter(rowData);
|
1188
|
+
}
|
1189
|
+
if(this._preTransform) {
|
1190
|
+
rowData = this._preTransform(rowData);
|
1191
|
+
}
|
1192
|
+
let i;
|
1193
|
+
let len = this._globalFilters.length;
|
1194
|
+
for(i = 0; i < len; ++i) {
|
1195
|
+
if(!this._globalFilters[i](rowData, rid, this._globalContexts[i])) {
|
1196
|
+
return false;
|
1197
|
+
}
|
1198
|
+
}
|
1199
|
+
|
1200
|
+
len = this._activeColFilters.length;
|
1201
|
+
if(len) {
|
1202
|
+
if(this._overridingFilter) {
|
1203
|
+
let ret = this._overridingFilter(rowData, rid);
|
1204
|
+
if(ret) {
|
1205
|
+
return (ret > 0);
|
1206
|
+
}
|
1207
|
+
}
|
1208
|
+
|
1209
|
+
if(this._rowTransform) {
|
1210
|
+
rowData = this._rowTransform(rowData);
|
1211
|
+
}
|
1212
|
+
|
1213
|
+
for(i = 0; i < len; ++i) {
|
1214
|
+
let cfo = this._activeColFilters[i];
|
1215
|
+
let jLen = cfo._filters.length;
|
1216
|
+
for(let j = 0; j < jLen; ++j) {
|
1217
|
+
if(
|
1218
|
+
!cfo._filters[j](
|
1219
|
+
rowData,
|
1220
|
+
rid,
|
1221
|
+
cfo._context[j]
|
1222
|
+
)
|
1223
|
+
) {
|
1224
|
+
return false;
|
1225
|
+
}
|
1226
|
+
}
|
1227
|
+
}
|
1228
|
+
}
|
1229
|
+
}
|
1230
|
+
return true;
|
1155
1231
|
};
|
1156
1232
|
/** @private */
|
1157
|
-
RowFilteringPlugin.prototype._requestFilterRefresh = function
|
1158
|
-
|
1159
|
-
|
1160
|
-
|
1233
|
+
RowFilteringPlugin.prototype._requestFilterRefresh = function() {
|
1234
|
+
if(!this._filterTimerId) {
|
1235
|
+
this._filterTimerId = setTimeout(this.refresh, 10);
|
1236
|
+
}
|
1161
1237
|
};
|
1162
1238
|
/** @private */
|
1163
|
-
RowFilteringPlugin.prototype._setTimerForUpdatingIcons = function
|
1164
|
-
|
1165
|
-
|
1166
|
-
|
1167
|
-
|
1168
|
-
|
1169
|
-
|
1239
|
+
RowFilteringPlugin.prototype._setTimerForUpdatingIcons = function() {
|
1240
|
+
if(this._iconActivation === "none") {
|
1241
|
+
return;
|
1242
|
+
}
|
1243
|
+
if(!this._uiTimerId) {
|
1244
|
+
this._uiTimerId = setTimeout(this._updateAllColumnIcons, 10);
|
1245
|
+
}
|
1170
1246
|
};
|
1171
1247
|
|
1172
1248
|
/** Perform filtering with the same parameters. Do not call this method repeatedly as the operation is quite expensive.
|
@@ -1174,118 +1250,124 @@ RowFilteringPlugin.prototype._setTimerForUpdatingIcons = function () {
|
|
1174
1250
|
* @suppress {checkTypes}
|
1175
1251
|
* @fires RowFilteringPlugin#refreshed
|
1176
1252
|
*/
|
1177
|
-
RowFilteringPlugin.prototype.refresh = function
|
1178
|
-
|
1179
|
-
|
1180
|
-
|
1181
|
-
|
1182
|
-
|
1183
|
-
|
1184
|
-
|
1185
|
-
|
1186
|
-
|
1187
|
-
|
1188
|
-
|
1189
|
-
|
1190
|
-
|
1191
|
-
|
1192
|
-
|
1193
|
-
|
1194
|
-
|
1195
|
-
|
1196
|
-
|
1197
|
-
|
1198
|
-
|
1199
|
-
|
1200
|
-
|
1201
|
-
|
1202
|
-
|
1203
|
-
|
1253
|
+
RowFilteringPlugin.prototype.refresh = function() {
|
1254
|
+
this._filterTimerId = 0;
|
1255
|
+
|
1256
|
+
this._activeColFilters = this._columnFilters;
|
1257
|
+
//check cstp
|
1258
|
+
let cstkp = this._getPlugin("ColumnStackPlugin");
|
1259
|
+
if(cstkp) {
|
1260
|
+
let colIndex, cfo;
|
1261
|
+
let host = this._hosts[0];
|
1262
|
+
let colCount = this._getColumnCount();
|
1263
|
+
|
1264
|
+
this._activeColFilters = [];
|
1265
|
+
for(colIndex = 0; colIndex < colCount; ++colIndex) {
|
1266
|
+
cfo = this._getColumnFilterOption(colIndex);
|
1267
|
+
if(cfo && host.getColumnVisibility(colIndex, 2)) {
|
1268
|
+
this._activeColFilters.push(cfo);
|
1269
|
+
}
|
1270
|
+
}
|
1271
|
+
}
|
1272
|
+
|
1273
|
+
let totalFilter = this._globalFilters.length + this._activeColFilters.length;
|
1274
|
+
let logic = (!this._disabled && totalFilter) ? this._filterLogic : null;
|
1275
|
+
|
1276
|
+
let dirty = 0;
|
1277
|
+
let dvs = this._getAvailableDataViews();
|
1278
|
+
for(let i = dvs.length; --i >= 0;) {
|
1279
|
+
dirty |= dvs[i].filterIn(logic);
|
1280
|
+
}
|
1281
|
+
|
1282
|
+
if(dirty) {
|
1283
|
+
this._dispatch("refreshed", {});
|
1284
|
+
}
|
1204
1285
|
};
|
1205
1286
|
/** @private
|
1206
1287
|
* @param {number} colIndex
|
1207
1288
|
*/
|
1208
|
-
RowFilteringPlugin.prototype._updateColumnIcon = function
|
1209
|
-
|
1210
|
-
|
1211
|
-
|
1212
|
-
|
1213
|
-
|
1214
|
-
|
1215
|
-
|
1216
|
-
|
1217
|
-
|
1218
|
-
|
1219
|
-
|
1220
|
-
|
1221
|
-
|
1222
|
-
|
1223
|
-
|
1224
|
-
|
1225
|
-
|
1226
|
-
|
1227
|
-
|
1228
|
-
|
1229
|
-
|
1230
|
-
|
1231
|
-
|
1232
|
-
|
1233
|
-
|
1234
|
-
|
1235
|
-
|
1236
|
-
|
1237
|
-
|
1238
|
-
|
1239
|
-
|
1240
|
-
|
1241
|
-
|
1242
|
-
|
1243
|
-
|
1244
|
-
|
1245
|
-
|
1246
|
-
|
1247
|
-
|
1248
|
-
|
1249
|
-
|
1250
|
-
|
1251
|
-
|
1252
|
-
|
1253
|
-
|
1254
|
-
|
1255
|
-
|
1256
|
-
|
1257
|
-
|
1258
|
-
|
1259
|
-
|
1260
|
-
|
1261
|
-
|
1262
|
-
|
1263
|
-
|
1264
|
-
|
1265
|
-
|
1266
|
-
|
1267
|
-
|
1268
|
-
|
1269
|
-
}
|
1289
|
+
RowFilteringPlugin.prototype._updateColumnIcon = function(colIndex) {
|
1290
|
+
let cfo = this._getColumnFilterOption(colIndex); // colData["rowFiltering"]["filterOption"]
|
1291
|
+
let colSettings = this._getUserColumnSettings(colIndex); // colData["rowFiltering"]
|
1292
|
+
let iconActivation = colSettings.filterIcon == false ? "none" : this._iconActivation;
|
1293
|
+
let hasFilter = cfo ? cfo._filters.length : 0;
|
1294
|
+
|
1295
|
+
for(let i = this._hosts.length; --i >= 0;) {
|
1296
|
+
let host = this._hosts[i];
|
1297
|
+
let tsect = host.getSection("title");
|
1298
|
+
if(!tsect) {
|
1299
|
+
continue;
|
1300
|
+
}
|
1301
|
+
let rCount = tsect.getRowCount();
|
1302
|
+
let cell = tsect.getCell(colIndex, rCount - 1, true); // Get bottom cell
|
1303
|
+
let column = tsect.getColumn(colIndex);
|
1304
|
+
if(!cell) {
|
1305
|
+
continue;
|
1306
|
+
}
|
1307
|
+
// HACK: Update cell padding for all type of icons (sorting and column grouping icons)
|
1308
|
+
if(cell["updatePadding"]) {
|
1309
|
+
cell["updatePadding"]();
|
1310
|
+
}
|
1311
|
+
|
1312
|
+
let isColumnMovable = host.isColumnMovable(colIndex);
|
1313
|
+
if(isColumnMovable) {
|
1314
|
+
column.enableClass("movable", true);
|
1315
|
+
} else {
|
1316
|
+
column.enableClass("movable", false);
|
1317
|
+
}
|
1318
|
+
|
1319
|
+
let onActiveFilter = iconActivation !== "always" && iconActivation !== "onHover";
|
1320
|
+
let noFilterIcon = this._disabled || iconActivation === "none" || (onActiveFilter && !hasFilter);
|
1321
|
+
if(!noFilterIcon) {
|
1322
|
+
if(!cell._filterIcon) {
|
1323
|
+
let filterIcon;
|
1324
|
+
if(ElfUtil.hasComponent("ef-icon") >= 3) {
|
1325
|
+
filterIcon = document.createElement("ef-icon");
|
1326
|
+
filterIcon.setAttribute("icon", "filter");
|
1327
|
+
} else {
|
1328
|
+
filterIcon = document.createElement("div");
|
1329
|
+
filterIcon.className = "filter-symbol icon-filter ef-icon";
|
1330
|
+
}
|
1331
|
+
filterIcon.classList.add("title-filter-icon"); // Icon reference
|
1332
|
+
filterIcon.addEventListener("click", this._onIconClicked, false);
|
1333
|
+
this._dispatch("iconCreated", {"icon": filterIcon, "colIndex": colIndex, "grid": host});
|
1334
|
+
cell.insertFloatingIcon(filterIcon, 10);
|
1335
|
+
cell._filterIcon = filterIcon;
|
1336
|
+
}
|
1337
|
+
if(hasFilter){
|
1338
|
+
cell.enableClass("active-filter", true);
|
1339
|
+
}else{
|
1340
|
+
cell.enableClass("active-filter", false);
|
1341
|
+
}
|
1342
|
+
} else {
|
1343
|
+
if(cell._filterIcon) {
|
1344
|
+
cell.removeFloatingIcon(cell._filterIcon);
|
1345
|
+
cell._filterIcon = null;
|
1346
|
+
cell.enableClass("active-filter", false);
|
1347
|
+
}
|
1348
|
+
}
|
1349
|
+
}
|
1270
1350
|
};
|
1271
1351
|
/** @private */
|
1272
|
-
RowFilteringPlugin.prototype._updateAllColumnIcons = function
|
1273
|
-
|
1274
|
-
|
1275
|
-
|
1276
|
-
|
1277
|
-
|
1352
|
+
RowFilteringPlugin.prototype._updateAllColumnIcons = function() {
|
1353
|
+
this._uiTimerId = 0;
|
1354
|
+
|
1355
|
+
let colCount = this._getColumnCount();
|
1356
|
+
for(let i = 0; i < colCount; ++i) {
|
1357
|
+
this._updateColumnIcon(i);
|
1358
|
+
}
|
1278
1359
|
};
|
1279
1360
|
|
1361
|
+
|
1280
1362
|
/** @private
|
1281
1363
|
* @return {number}
|
1282
1364
|
*/
|
1283
|
-
RowFilteringPlugin.prototype._getColumnCount = function
|
1284
|
-
|
1285
|
-
|
1286
|
-
|
1287
|
-
|
1288
|
-
|
1365
|
+
RowFilteringPlugin.prototype._getColumnCount = function() {
|
1366
|
+
let grid = this._hosts[0];
|
1367
|
+
if(grid) {
|
1368
|
+
return grid.getColumnCount();
|
1369
|
+
}
|
1370
|
+
return 0;
|
1289
1371
|
};
|
1290
1372
|
|
1291
1373
|
/** Update existing filter state by replacing the old one. Note that filtering will be performed asynchronously after executing this method.
|
@@ -1294,70 +1376,70 @@ RowFilteringPlugin.prototype._getColumnCount = function () {
|
|
1294
1376
|
* @param {*} ctx Context object that will be passed as the third parameter for the filter logic
|
1295
1377
|
* @return {boolean} Returns true if there is any change
|
1296
1378
|
*/
|
1297
|
-
RowFilteringPlugin.prototype.setColumnFilterState = function
|
1298
|
-
|
1299
|
-
|
1300
|
-
|
1301
|
-
|
1302
|
-
|
1303
|
-
|
1304
|
-
|
1379
|
+
RowFilteringPlugin.prototype.setColumnFilterState = function(colIndex, ctx) {
|
1380
|
+
let cfo = this._getColumnFilterOption(colIndex);
|
1381
|
+
if(cfo) {
|
1382
|
+
cfo._context[0] = ctx;
|
1383
|
+
this._requestFilterRefresh();
|
1384
|
+
return true;
|
1385
|
+
}
|
1386
|
+
return false;
|
1305
1387
|
};
|
1306
1388
|
/** Get the stored user context from the specified column
|
1307
1389
|
* @public
|
1308
1390
|
* @param {number} colIndex
|
1309
1391
|
* @return {*} Context object that is passed as the third parameter for the filter logic
|
1310
1392
|
*/
|
1311
|
-
RowFilteringPlugin.prototype.getColumnFilterState = function
|
1312
|
-
|
1313
|
-
|
1314
|
-
|
1315
|
-
|
1316
|
-
|
1393
|
+
RowFilteringPlugin.prototype.getColumnFilterState = function(colIndex) {
|
1394
|
+
let cfo = this._getColumnFilterOption(colIndex);
|
1395
|
+
if(cfo) {
|
1396
|
+
return cfo._context[0];
|
1397
|
+
}
|
1398
|
+
return null;
|
1317
1399
|
};
|
1318
1400
|
/** Deprecated in favor of getConfigObject(). Get the stored user context from all columns. The column with no filter will return null value
|
1319
1401
|
* @public
|
1320
1402
|
* @return {!Array} Array of context objects
|
1321
1403
|
* @see {@link RowFilteringPlugin.getConfigObject}
|
1322
1404
|
*/
|
1323
|
-
RowFilteringPlugin.prototype.getColumnFilterStates = function
|
1324
|
-
|
1325
|
-
|
1326
|
-
|
1327
|
-
|
1328
|
-
|
1329
|
-
|
1405
|
+
RowFilteringPlugin.prototype.getColumnFilterStates = function() {
|
1406
|
+
let colCount = this._hosts[0] ? this._hosts[0].getColumnCount() : 0;
|
1407
|
+
let states = new Array(colCount);
|
1408
|
+
for(let c = 0; c < colCount; ++c) {
|
1409
|
+
states[c] = this.getColumnFilterState(c);
|
1410
|
+
}
|
1411
|
+
return states;
|
1330
1412
|
};
|
1331
1413
|
|
1332
1414
|
/** @private
|
1333
1415
|
* @return {!Array.<Object>} array of DataView
|
1334
1416
|
*/
|
1335
|
-
RowFilteringPlugin.prototype._getAvailableDataViews = function
|
1336
|
-
|
1337
|
-
|
1338
|
-
|
1339
|
-
|
1340
|
-
|
1341
|
-
|
1342
|
-
|
1343
|
-
|
1344
|
-
|
1345
|
-
|
1346
|
-
|
1347
|
-
|
1348
|
-
|
1349
|
-
|
1417
|
+
RowFilteringPlugin.prototype._getAvailableDataViews = function() {
|
1418
|
+
if(this._dvs.length) {
|
1419
|
+
return this._dvs;
|
1420
|
+
} else {
|
1421
|
+
let len = this._hosts.length;
|
1422
|
+
let ary = [];
|
1423
|
+
for(let i = 0; i < len; ++i) {
|
1424
|
+
let host = this._hosts[i];
|
1425
|
+
let dv = host.getDataSource();
|
1426
|
+
if(dv) {
|
1427
|
+
ary.push(dv);
|
1428
|
+
}
|
1429
|
+
}
|
1430
|
+
return ary;
|
1431
|
+
}
|
1350
1432
|
};
|
1351
1433
|
/** @private
|
1352
1434
|
* @param {Object} dv DataView
|
1353
1435
|
* @return {Object} DataTable
|
1354
1436
|
*/
|
1355
|
-
RowFilteringPlugin.prototype._getDataTable = function
|
1356
|
-
|
1357
|
-
|
1358
|
-
|
1359
|
-
|
1360
|
-
|
1437
|
+
RowFilteringPlugin.prototype._getDataTable = function(dv) {
|
1438
|
+
let dt = dv ? dv.getDataSource() : null;
|
1439
|
+
while(dt && dt.getDataSource()) {
|
1440
|
+
dt = dt.getDataSource();
|
1441
|
+
}
|
1442
|
+
return dt;
|
1361
1443
|
};
|
1362
1444
|
|
1363
1445
|
/** @public
|
@@ -1372,12 +1454,12 @@ RowFilteringPlugin.prototype._getDataTable = function (dv) {
|
|
1372
1454
|
* @param {Object=} selectedItems
|
1373
1455
|
* @return {Object} Object that maps formatted value to array of raw values
|
1374
1456
|
*/
|
1375
|
-
RowFilteringPlugin.prototype.getUniqueValues = function
|
1376
|
-
|
1377
|
-
|
1378
|
-
|
1379
|
-
|
1380
|
-
|
1457
|
+
RowFilteringPlugin.prototype.getUniqueValues = function(field, formatter, fmtField, rawDataAccessor, formattedDataAccessor, filterFuncs, selectedItems) {
|
1458
|
+
let dialogConfig = {
|
1459
|
+
rawDataAccessor: rawDataAccessor,
|
1460
|
+
formattedDataAccessor: formattedDataAccessor
|
1461
|
+
};
|
1462
|
+
return this._getUniqueValues(field, dialogConfig, formatter, filterFuncs, selectedItems);
|
1381
1463
|
};
|
1382
1464
|
|
1383
1465
|
/** @private
|
@@ -1385,25 +1467,24 @@ RowFilteringPlugin.prototype.getUniqueValues = function (field, formatter, fmtFi
|
|
1385
1467
|
* @param {*} rawVal
|
1386
1468
|
* @returns {string}
|
1387
1469
|
*/
|
1388
|
-
|
1389
|
-
|
1390
|
-
|
1391
|
-
|
1392
|
-
|
1393
|
-
|
1394
|
-
|
1395
|
-
|
1396
|
-
|
1397
|
-
|
1398
|
-
|
1399
|
-
|
1400
|
-
|
1401
|
-
|
1402
|
-
|
1403
|
-
|
1404
|
-
|
1405
|
-
|
1406
|
-
return "";
|
1470
|
+
let _valueToString = function(formattedVal, rawVal) {
|
1471
|
+
if(typeof formattedVal === "string") {
|
1472
|
+
return formattedVal;
|
1473
|
+
}
|
1474
|
+
if(formattedVal) {
|
1475
|
+
if(typeof formattedVal != "object") {
|
1476
|
+
return rawVal + "";
|
1477
|
+
} else if(formattedVal instanceof Date) {
|
1478
|
+
return formattedVal.toLocaleString("en-GB");
|
1479
|
+
} else { // Object type cannot be converted to string
|
1480
|
+
return"";
|
1481
|
+
}
|
1482
|
+
} else if(formattedVal === 0) {
|
1483
|
+
return "0";
|
1484
|
+
} else if(formattedVal === false) {
|
1485
|
+
return "false";
|
1486
|
+
}
|
1487
|
+
return "";
|
1407
1488
|
};
|
1408
1489
|
/** @private
|
1409
1490
|
* @param {Object} selectedItems
|
@@ -1412,36 +1493,34 @@ var _valueToString = function _valueToString(formattedVal, rawVal) {
|
|
1412
1493
|
* @param {!Array.<Function>} filterFuncs A selector function that execute on each item to determine the selection
|
1413
1494
|
* @return {boolean}
|
1414
1495
|
*/
|
1415
|
-
|
1416
|
-
|
1417
|
-
|
1418
|
-
|
1419
|
-
|
1420
|
-
|
1421
|
-
|
1422
|
-
|
1423
|
-
|
1424
|
-
|
1425
|
-
|
1426
|
-
|
1427
|
-
|
1496
|
+
let _collectSelectedItem = function(selectedItems, formattedVal, row, filterFuncs) {
|
1497
|
+
if(filterFuncs) {
|
1498
|
+
if(!selectedItems[formattedVal]) {
|
1499
|
+
for(let i = filterFuncs.length; --i >= 0;) {
|
1500
|
+
if(!filterFuncs[i](row)) {
|
1501
|
+
return false;
|
1502
|
+
}
|
1503
|
+
}
|
1504
|
+
selectedItems[formattedVal] = true;
|
1505
|
+
return true;
|
1506
|
+
}
|
1507
|
+
}
|
1508
|
+
return false;
|
1428
1509
|
};
|
1429
1510
|
/** @private
|
1430
1511
|
* @param {Object} uniqueValues
|
1431
1512
|
* @param {string} formattedVal
|
1432
1513
|
* @param {*} rawVal
|
1433
1514
|
*/
|
1434
|
-
|
1435
|
-
|
1436
|
-
|
1437
|
-
|
1438
|
-
|
1439
|
-
|
1440
|
-
|
1441
|
-
|
1442
|
-
|
1443
|
-
uniqueValues[formattedVal] = [rawVal];
|
1444
|
-
}
|
1515
|
+
let _collectUniqueValue = function(uniqueValues, formattedVal, rawVal) {
|
1516
|
+
let rawValues = uniqueValues[formattedVal];
|
1517
|
+
if(rawValues) {
|
1518
|
+
if(rawValues.indexOf(rawVal) < 0) { // Check for unique raw values
|
1519
|
+
rawValues.push(rawVal);
|
1520
|
+
}
|
1521
|
+
} else { // The first unique formatted value detected
|
1522
|
+
uniqueValues[formattedVal] = [rawVal];
|
1523
|
+
}
|
1445
1524
|
};
|
1446
1525
|
/** @private
|
1447
1526
|
* @param {string} field A field name for getting raw value from row data
|
@@ -1451,94 +1530,101 @@ var _collectUniqueValue = function _collectUniqueValue(uniqueValues, formattedVa
|
|
1451
1530
|
* @param {Object} selectedItems
|
1452
1531
|
* @return {Object} Object that maps formatted value to array of raw values
|
1453
1532
|
*/
|
1454
|
-
RowFilteringPlugin.prototype._getUniqueValues = function
|
1455
|
-
|
1456
|
-
|
1457
|
-
|
1458
|
-
|
1459
|
-
|
1460
|
-
|
1461
|
-
|
1462
|
-
|
1463
|
-
|
1464
|
-
|
1465
|
-
|
1466
|
-
|
1467
|
-
|
1468
|
-
|
1469
|
-
|
1470
|
-
|
1471
|
-
|
1472
|
-
|
1473
|
-
|
1474
|
-
|
1475
|
-
|
1476
|
-
|
1477
|
-
|
1478
|
-
|
1479
|
-
|
1480
|
-
|
1481
|
-
|
1482
|
-
|
1483
|
-
|
1484
|
-
|
1485
|
-
|
1486
|
-
|
1487
|
-
|
1488
|
-
|
1489
|
-
|
1490
|
-
|
1491
|
-
|
1492
|
-
|
1493
|
-
|
1494
|
-
|
1495
|
-
|
1496
|
-
|
1497
|
-
|
1498
|
-
|
1499
|
-
|
1500
|
-
|
1501
|
-
|
1502
|
-
|
1503
|
-
|
1504
|
-
|
1505
|
-
|
1506
|
-
|
1507
|
-
|
1508
|
-
|
1509
|
-
|
1510
|
-
|
1511
|
-
|
1512
|
-
|
1513
|
-
|
1514
|
-
|
1515
|
-
|
1516
|
-
|
1517
|
-
|
1518
|
-
|
1519
|
-
|
1520
|
-
|
1521
|
-
|
1522
|
-
|
1523
|
-
|
1533
|
+
RowFilteringPlugin.prototype._getUniqueValues = function(field, dialogConfig, formatter, filterFuncs, selectedItems) {
|
1534
|
+
if(!field) {
|
1535
|
+
return null;
|
1536
|
+
}
|
1537
|
+
|
1538
|
+
let rawDataAccessor = (dialogConfig.rawDataAccessor || null);
|
1539
|
+
let formattedDataAccessor = (dialogConfig.formattedDataAccessor || null);
|
1540
|
+
let userItemList = dialogConfig.itemList;
|
1541
|
+
|
1542
|
+
let uniqueValues = {};
|
1543
|
+
let formattedVal = null;
|
1544
|
+
let rawVal = null;
|
1545
|
+
if(!Array.isArray(userItemList)) {
|
1546
|
+
userItemList = null;
|
1547
|
+
let dvs = this._getAvailableDataViews();
|
1548
|
+
let dts = dvs.map(this._getDataTable);
|
1549
|
+
let tblCount = dts.length;
|
1550
|
+
for(let t = 0; t < tblCount; ++t) {
|
1551
|
+
let rows = dts[t].getAllRowData();
|
1552
|
+
let rowCount = rows.length;
|
1553
|
+
for(let r = 0; r < rowCount; ++r) {
|
1554
|
+
let row = rows[r];
|
1555
|
+
if(this._rowGetter) {
|
1556
|
+
row = this._rowGetter(row);
|
1557
|
+
}
|
1558
|
+
if(this._rowTransform) {
|
1559
|
+
row = this._rowTransform(row);
|
1560
|
+
}
|
1561
|
+
let fieldVal = row[field];
|
1562
|
+
rawVal = fieldVal;
|
1563
|
+
if(rawDataAccessor) {
|
1564
|
+
rawVal = rawDataAccessor(rawVal);
|
1565
|
+
}
|
1566
|
+
|
1567
|
+
if(!rawVal) { // Only valid values are accepted
|
1568
|
+
if(rawVal !== 0 && rawVal !== false) {
|
1569
|
+
continue;
|
1570
|
+
}
|
1571
|
+
}
|
1572
|
+
|
1573
|
+
formattedVal = rawVal;
|
1574
|
+
if(formattedDataAccessor) {
|
1575
|
+
formattedVal = formattedDataAccessor(fieldVal); // The function takes data value
|
1576
|
+
} else if(formatter) {
|
1577
|
+
formattedVal = formatter(row); // The function takes row data
|
1578
|
+
}
|
1579
|
+
|
1580
|
+
formattedVal = _valueToString(formattedVal, rawVal);
|
1581
|
+
if(formattedVal) {
|
1582
|
+
_collectSelectedItem(selectedItems, formattedVal, row, filterFuncs);
|
1583
|
+
_collectUniqueValue(uniqueValues, formattedVal, rawVal);
|
1584
|
+
}
|
1585
|
+
}
|
1586
|
+
}
|
1587
|
+
}
|
1588
|
+
|
1589
|
+
userItemList = _arrayConcat(userItemList, dialogConfig.additionalItems);
|
1590
|
+
|
1591
|
+
let dummyRow = {};
|
1592
|
+
let userItemCount = userItemList ? userItemList.length : 0;
|
1593
|
+
for(let i = 0; i < userItemCount; ++i) {
|
1594
|
+
rawVal = dummyRow[field] = userItemList[i];
|
1595
|
+
formattedVal = rawVal;
|
1596
|
+
if(formattedDataAccessor) {
|
1597
|
+
formattedVal = formattedDataAccessor(rawVal);
|
1598
|
+
} else if(formatter) {
|
1599
|
+
formattedVal = formatter(dummyRow);
|
1600
|
+
}
|
1601
|
+
|
1602
|
+
formattedVal = _valueToString(formattedVal, rawVal);
|
1603
|
+
if(formattedVal) {
|
1604
|
+
_collectSelectedItem(selectedItems, formattedVal, dummyRow, filterFuncs);
|
1605
|
+
_collectUniqueValue(uniqueValues, formattedVal, rawVal);
|
1606
|
+
}
|
1607
|
+
}
|
1608
|
+
return uniqueValues;
|
1524
1609
|
};
|
1525
1610
|
|
1611
|
+
|
1526
1612
|
/** @private
|
1527
1613
|
* @function
|
1528
1614
|
* @returns {Element}
|
1529
1615
|
*/
|
1530
|
-
RowFilteringPlugin._createDialog = function
|
1531
|
-
|
1532
|
-
|
1533
|
-
|
1534
|
-
|
1535
|
-
|
1536
|
-
|
1537
|
-
|
1538
|
-
|
1539
|
-
|
1540
|
-
|
1541
|
-
|
1616
|
+
RowFilteringPlugin._createDialog = function() {
|
1617
|
+
let tag = RowFilteringPlugin._dialogTagName;
|
1618
|
+
if(tag == null) {
|
1619
|
+
let dialogVersion = ElfUtil.hasComponent("filter-dialog"); // WARNING: this cannot detect version 2 or less
|
1620
|
+
if(dialogVersion) {
|
1621
|
+
RowFilteringPlugin._dialogTagName = (dialogVersion >= 3) ? "filter-dialog" : "tr-grid-filter-dialog";
|
1622
|
+
} else {
|
1623
|
+
RowFilteringPlugin._dialogTagName = "";
|
1624
|
+
}
|
1625
|
+
tag = RowFilteringPlugin._dialogTagName;
|
1626
|
+
}
|
1627
|
+
return tag ? document.createElement(tag) : null;
|
1542
1628
|
};
|
1543
1629
|
/** @private
|
1544
1630
|
* @function
|
@@ -1547,508 +1633,531 @@ RowFilteringPlugin._createDialog = function () {
|
|
1547
1633
|
* @param {Function} formatter
|
1548
1634
|
* @returns {Array}
|
1549
1635
|
*/
|
1550
|
-
RowFilteringPlugin._formatArrayExpression = function
|
1551
|
-
|
1552
|
-
|
1553
|
-
|
1554
|
-
|
1555
|
-
|
1556
|
-
|
1557
|
-
|
1558
|
-
|
1559
|
-
|
1560
|
-
|
1561
|
-
|
1562
|
-
|
1563
|
-
|
1564
|
-
|
1565
|
-
|
1566
|
-
|
1567
|
-
|
1568
|
-
|
1569
|
-
|
1570
|
-
|
1571
|
-
|
1572
|
-
|
1573
|
-
|
1574
|
-
|
1636
|
+
RowFilteringPlugin._formatArrayExpression = function(exp, field, formatter) {
|
1637
|
+
if(Array.isArray(exp)) {
|
1638
|
+
let ary = exp.slice(); // Clone to avoid modifying original data
|
1639
|
+
let formattedVal = ary[1];
|
1640
|
+
let val = stringToDateObject(formattedVal);
|
1641
|
+
if(val !== formattedVal) {
|
1642
|
+
ary.rawValue = val;
|
1643
|
+
ary.formattedValue = formattedVal;
|
1644
|
+
}
|
1645
|
+
if(field && formatter && typeof val !== "string") {
|
1646
|
+
if(val != null) {
|
1647
|
+
let dummyRow = {};
|
1648
|
+
dummyRow[field] = val;
|
1649
|
+
formattedVal = formatter(dummyRow);
|
1650
|
+
if(formattedVal) {
|
1651
|
+
ary.rawValue = val;
|
1652
|
+
ary.formattedValue = formattedVal;
|
1653
|
+
val = formattedVal;
|
1654
|
+
}
|
1655
|
+
}
|
1656
|
+
}
|
1657
|
+
ary[1] = val;
|
1658
|
+
return ary;
|
1659
|
+
}
|
1660
|
+
return null;
|
1575
1661
|
};
|
1576
1662
|
/** @public
|
1577
1663
|
* @param {number} colIndex
|
1578
1664
|
* @param {RowFilteringPlugin~FilterDialogOptions=} runtimeDialogOptions
|
1579
1665
|
*/
|
1580
|
-
RowFilteringPlugin.prototype.openDialog = function
|
1581
|
-
|
1582
|
-
|
1583
|
-
|
1584
|
-
|
1585
|
-
|
1586
|
-
|
1587
|
-
|
1588
|
-
|
1589
|
-
|
1590
|
-
|
1591
|
-
|
1592
|
-
|
1593
|
-
|
1594
|
-
|
1595
|
-
|
1596
|
-
|
1597
|
-
|
1598
|
-
|
1599
|
-
|
1600
|
-
|
1601
|
-
|
1602
|
-
|
1603
|
-
|
1604
|
-
|
1605
|
-
|
1606
|
-
|
1607
|
-
|
1608
|
-
|
1609
|
-
|
1610
|
-
|
1611
|
-
|
1612
|
-
|
1613
|
-
|
1614
|
-
|
1615
|
-
|
1616
|
-
|
1617
|
-
|
1618
|
-
|
1619
|
-
|
1620
|
-
|
1621
|
-
|
1622
|
-
|
1623
|
-
|
1624
|
-
|
1625
|
-
|
1626
|
-
|
1627
|
-
|
1628
|
-
|
1629
|
-
|
1630
|
-
|
1631
|
-
|
1632
|
-
|
1633
|
-
|
1634
|
-
|
1635
|
-
|
1636
|
-
|
1637
|
-
|
1638
|
-
|
1639
|
-
|
1640
|
-
|
1641
|
-
|
1642
|
-
|
1643
|
-
|
1644
|
-
|
1645
|
-
|
1646
|
-
|
1647
|
-
|
1648
|
-
|
1649
|
-
|
1650
|
-
|
1651
|
-
|
1652
|
-
|
1653
|
-
|
1654
|
-
|
1655
|
-
|
1656
|
-
|
1657
|
-
|
1658
|
-
|
1659
|
-
|
1660
|
-
|
1661
|
-
|
1662
|
-
|
1663
|
-
|
1664
|
-
|
1665
|
-
|
1666
|
-
|
1667
|
-
|
1668
|
-
|
1669
|
-
|
1670
|
-
|
1671
|
-
|
1672
|
-
|
1673
|
-
|
1674
|
-
|
1675
|
-
|
1676
|
-
|
1677
|
-
|
1678
|
-
|
1679
|
-
|
1680
|
-
|
1681
|
-
|
1682
|
-
|
1683
|
-
|
1684
|
-
|
1685
|
-
|
1686
|
-
|
1687
|
-
|
1688
|
-
|
1689
|
-
|
1690
|
-
|
1691
|
-
|
1692
|
-
|
1693
|
-
|
1694
|
-
|
1695
|
-
|
1696
|
-
|
1697
|
-
|
1698
|
-
|
1699
|
-
|
1700
|
-
|
1701
|
-
|
1702
|
-
|
1703
|
-
|
1704
|
-
|
1705
|
-
|
1706
|
-
|
1707
|
-
|
1708
|
-
|
1709
|
-
|
1710
|
-
|
1711
|
-
|
1712
|
-
|
1713
|
-
|
1714
|
-
|
1715
|
-
|
1716
|
-
|
1717
|
-
|
1718
|
-
|
1719
|
-
|
1720
|
-
|
1721
|
-
|
1722
|
-
|
1723
|
-
|
1724
|
-
|
1725
|
-
|
1726
|
-
|
1727
|
-
|
1728
|
-
|
1729
|
-
|
1730
|
-
|
1731
|
-
|
1732
|
-
|
1733
|
-
|
1734
|
-
|
1735
|
-
|
1736
|
-
|
1737
|
-
|
1738
|
-
|
1739
|
-
|
1740
|
-
|
1741
|
-
|
1742
|
-
|
1743
|
-
|
1744
|
-
|
1745
|
-
|
1746
|
-
|
1747
|
-
|
1748
|
-
|
1749
|
-
|
1750
|
-
|
1751
|
-
|
1752
|
-
|
1753
|
-
|
1754
|
-
|
1755
|
-
|
1756
|
-
|
1757
|
-
|
1758
|
-
|
1759
|
-
|
1760
|
-
|
1761
|
-
|
1762
|
-
|
1763
|
-
|
1764
|
-
|
1765
|
-
|
1766
|
-
|
1767
|
-
|
1768
|
-
|
1769
|
-
|
1770
|
-
|
1771
|
-
|
1772
|
-
|
1773
|
-
|
1774
|
-
|
1775
|
-
|
1776
|
-
|
1777
|
-
|
1778
|
-
|
1779
|
-
|
1780
|
-
|
1781
|
-
|
1782
|
-
|
1783
|
-
|
1666
|
+
RowFilteringPlugin.prototype.openDialog = function(colIndex, runtimeDialogOptions) {
|
1667
|
+
let stp = this._getPlugin("SortableTitlePlugin");
|
1668
|
+
|
1669
|
+
if(!this._filterDialog || !this._dialogInitialized) {
|
1670
|
+
if(!this._filterDialog) {
|
1671
|
+
this._filterDialog = RowFilteringPlugin._createDialog();
|
1672
|
+
}
|
1673
|
+
|
1674
|
+
if(this._filterDialog) {
|
1675
|
+
this._dialogInitialized = true;
|
1676
|
+
if(!stp) {
|
1677
|
+
this._filterDialog.hideSortUI();
|
1678
|
+
} else {
|
1679
|
+
this._filterDialog.addEventListener("sortChanged", this._onDialogSortChanged.bind(this));
|
1680
|
+
}
|
1681
|
+
this._filterDialog.addEventListener("filterChanged", this._onDialogFilterChanged.bind(this));
|
1682
|
+
}
|
1683
|
+
}
|
1684
|
+
|
1685
|
+
if(!this._filterDialog) {
|
1686
|
+
console.log("Filter dialog does not exist");
|
1687
|
+
return;
|
1688
|
+
}
|
1689
|
+
|
1690
|
+
if(this._filterDialog.isShown) {
|
1691
|
+
this._filterDialog.hide(); // Hide previously opened dialog
|
1692
|
+
if(this._filterDialog._colIndex === colIndex) { // The dialog is already openned
|
1693
|
+
return; // Toggle open state
|
1694
|
+
}
|
1695
|
+
}
|
1696
|
+
|
1697
|
+
let host = this._hosts[0];
|
1698
|
+
if(!host) {
|
1699
|
+
return;
|
1700
|
+
}
|
1701
|
+
|
1702
|
+
// Find target cell for positioning filter dialog
|
1703
|
+
let tsect = host.getSection("title");
|
1704
|
+
if(!tsect) {
|
1705
|
+
return;
|
1706
|
+
}
|
1707
|
+
let rCount = tsect.getRowCount();
|
1708
|
+
let cell = tsect.getCell(colIndex, rCount - 1, true); // Get bottom cell
|
1709
|
+
if(!cell || !cell.getElement()) {
|
1710
|
+
return;
|
1711
|
+
}
|
1712
|
+
|
1713
|
+
// TODO: Handle newly inserted/added columns
|
1714
|
+
let field = this._getField(colIndex);
|
1715
|
+
if(!field) {
|
1716
|
+
return; // The specified column has no field
|
1717
|
+
}
|
1718
|
+
|
1719
|
+
if(this.hasListener("beforeDialogOpened")) {
|
1720
|
+
let arg = {
|
1721
|
+
colIndex: colIndex,
|
1722
|
+
field: field,
|
1723
|
+
grid: host
|
1724
|
+
};
|
1725
|
+
if(runtimeDialogOptions) {
|
1726
|
+
arg["dialogOptions"] = runtimeDialogOptions;
|
1727
|
+
}
|
1728
|
+
this._dispatch("beforeDialogOpened", arg);
|
1729
|
+
if(arg["cancel"]) {
|
1730
|
+
return;
|
1731
|
+
}
|
1732
|
+
if(arg["dialogOptions"]) {
|
1733
|
+
runtimeDialogOptions = arg["dialogOptions"];
|
1734
|
+
}
|
1735
|
+
}
|
1736
|
+
|
1737
|
+
if(typeof runtimeDialogOptions !== "object") {
|
1738
|
+
runtimeDialogOptions = null;
|
1739
|
+
}
|
1740
|
+
|
1741
|
+
if(stp) {
|
1742
|
+
this._filterDialog.setSortState(stp.getSortOrder(colIndex)); // This is for ELF v3
|
1743
|
+
}
|
1744
|
+
|
1745
|
+
// Setting up dialog configuration
|
1746
|
+
let colData = host.getColumnData(colIndex);
|
1747
|
+
let formatOptions = colData.formatOptions;
|
1748
|
+
let useUTCTime = false;
|
1749
|
+
if(formatOptions){
|
1750
|
+
if(formatOptions.formatType){
|
1751
|
+
useUTCTime = true;
|
1752
|
+
if(formatOptions.useUTCTime != null){
|
1753
|
+
useUTCTime = formatOptions.useUTCTime;
|
1754
|
+
}
|
1755
|
+
}
|
1756
|
+
}
|
1757
|
+
|
1758
|
+
let dialogConfig = { // default config
|
1759
|
+
sortUI: true,
|
1760
|
+
filterUI: true,
|
1761
|
+
fieldDataType: "",
|
1762
|
+
lang: "",
|
1763
|
+
rawDataAccessor: null,
|
1764
|
+
formattedDataAccessor: null,
|
1765
|
+
sortLogic: null,
|
1766
|
+
blankValues: false,
|
1767
|
+
blankValuesChecked: false
|
1768
|
+
};
|
1769
|
+
|
1770
|
+
let columnDialogOptions = null;
|
1771
|
+
let colSettings = this._getUserColumnSettings(colIndex); // colData["rowFiltering"]
|
1772
|
+
if(colSettings.fieldDataType){
|
1773
|
+
// TODO: Use data type from Composite Grid (getColumnDataType) or Realtime Grid (getDataType) instead
|
1774
|
+
columnDialogOptions = {
|
1775
|
+
fieldDataType: colSettings.fieldDataType
|
1776
|
+
};
|
1777
|
+
}
|
1778
|
+
|
1779
|
+
RowFilteringPlugin._overrideConfig(dialogConfig, this._dialogOptions);
|
1780
|
+
RowFilteringPlugin._overrideConfig(dialogConfig, columnDialogOptions);
|
1781
|
+
RowFilteringPlugin._overrideConfig(dialogConfig, runtimeDialogOptions);
|
1782
|
+
|
1783
|
+
// cfo is required for storing unique entries in the dialog, even though no filter is active
|
1784
|
+
// TODO: move rawDataAccessor and other settings to colSettings
|
1785
|
+
let cfo = this._initColumnFilterOption(colIndex); // colData["rowFiltering"]["filterOption"]
|
1786
|
+
cfo._rawDataAccessor = (dialogConfig.rawDataAccessor || null);
|
1787
|
+
cfo._formattedDataAccessor = (dialogConfig.formattedDataAccessor || null);
|
1788
|
+
let sortLogic = dialogConfig.sortLogic || null;
|
1789
|
+
|
1790
|
+
// Populate data for filter dialog based on existing states
|
1791
|
+
let formatter = this._getFormatter(colIndex);
|
1792
|
+
let condition2D = null;
|
1793
|
+
let filterMode = ""; // default
|
1794
|
+
let filterFuncs = null;
|
1795
|
+
let exp = colSettings.expression;
|
1796
|
+
if(exp) {
|
1797
|
+
if(Array.isArray(exp)) {
|
1798
|
+
if(exp.length) {
|
1799
|
+
condition2D = Array.isArray(exp[0]) ? exp.slice() : [exp]; // Guaranteed condition2D to be a 2D array
|
1800
|
+
condition2D[0] = RowFilteringPlugin._formatArrayExpression(condition2D[0], field, formatter);
|
1801
|
+
condition2D[1] = RowFilteringPlugin._formatArrayExpression(condition2D[1], field, formatter);
|
1802
|
+
filterMode = "advanced";
|
1803
|
+
}
|
1804
|
+
} else if(typeof exp === "function" || typeof exp === "string" || typeof exp === "object") {
|
1805
|
+
if(cfo._filters && cfo._filters.length) {
|
1806
|
+
filterFuncs = cfo._filters;
|
1807
|
+
}
|
1808
|
+
if(typeof exp === "object") {
|
1809
|
+
dialogConfig.additionalItems = _arrayConcat(dialogConfig.additionalItems, Object.keys(exp));
|
1810
|
+
}
|
1811
|
+
}
|
1812
|
+
}
|
1813
|
+
|
1814
|
+
let selectedItems = {};
|
1815
|
+
let uniqueValues = cfo.uniqueValues = this._getUniqueValues(
|
1816
|
+
field,
|
1817
|
+
dialogConfig,
|
1818
|
+
formatter,
|
1819
|
+
filterFuncs,
|
1820
|
+
selectedItems
|
1821
|
+
);
|
1822
|
+
|
1823
|
+
if(dialogConfig.blankValues) {
|
1824
|
+
delete uniqueValues[BLANKS];
|
1825
|
+
let dunmmySelectItem = {};
|
1826
|
+
let blkVals = ["", null, undefined, NaN]; // eslint-disable-line
|
1827
|
+
let dummyRow = {};
|
1828
|
+
for(let i = 0; i < blkVals.length; i++) {
|
1829
|
+
let blkVal = blkVals[i];
|
1830
|
+
dummyRow[field] = blkVal;
|
1831
|
+
|
1832
|
+
if(_collectSelectedItem(dunmmySelectItem, BLANKS, dummyRow, filterFuncs)) {
|
1833
|
+
dialogConfig.blankValuesChecked = true;
|
1834
|
+
break;
|
1835
|
+
}
|
1836
|
+
}
|
1837
|
+
}
|
1838
|
+
|
1839
|
+
let keys = Object.keys(uniqueValues);
|
1840
|
+
if(sortLogic) {
|
1841
|
+
keys.sort(function (a, b) {
|
1842
|
+
let rawValueA = uniqueValues[a][0];
|
1843
|
+
let rawValueB = uniqueValues[b][0];
|
1844
|
+
return sortLogic(rawValueA, rawValueB); // Compare with rawValue
|
1845
|
+
});
|
1846
|
+
}
|
1847
|
+
|
1848
|
+
let items = keys.map(function(formattedVal, idx) {
|
1849
|
+
return {
|
1850
|
+
id: idx,
|
1851
|
+
title: formattedVal,
|
1852
|
+
nodes: [],
|
1853
|
+
checked: selectedItems[formattedVal] ? true : false
|
1854
|
+
};
|
1855
|
+
});
|
1856
|
+
|
1857
|
+
// Adding inputs from conditions to uniqueValues for mapping back from the dialog
|
1858
|
+
if(condition2D) {
|
1859
|
+
let cond = condition2D[0];
|
1860
|
+
if(cond && cond.formattedValue) {
|
1861
|
+
if(!uniqueValues[cond.formattedValue]) {
|
1862
|
+
uniqueValues[cond.formattedValue] = [cond.rawValue];
|
1863
|
+
}
|
1864
|
+
}
|
1865
|
+
cond = condition2D[1];
|
1866
|
+
if(cond && cond.formattedValue) {
|
1867
|
+
if(!uniqueValues[cond.formattedValue]) {
|
1868
|
+
uniqueValues[cond.formattedValue] = [cond.rawValue];
|
1869
|
+
}
|
1870
|
+
}
|
1871
|
+
}
|
1872
|
+
|
1873
|
+
// Initialize dialog
|
1874
|
+
if(this._filterDialog.init) { // TODO: support initiailization in v1
|
1875
|
+
this._filterDialog.init(dialogConfig);
|
1876
|
+
}
|
1877
|
+
|
1878
|
+
// TODO: Move all settings to configuration object
|
1879
|
+
this._filterDialog.useUTCTime = useUTCTime;
|
1880
|
+
this._filterDialog.target = cell.getElement();
|
1881
|
+
this._filterDialog._colIndex = colIndex;
|
1882
|
+
this._filterDialog.data = items; // TODO: Move all settings to configuration object
|
1883
|
+
this._filterDialog.filterMode = filterMode;
|
1884
|
+
this._filterDialog.conditions = condition2D;
|
1885
|
+
this._filterDialog.show();
|
1784
1886
|
};
|
1785
1887
|
/** @private
|
1786
1888
|
* @function
|
1787
1889
|
* @param {Object} config
|
1788
1890
|
* @param {RowFilteringPlugin~FilterDialogOptions=} userConfig
|
1789
1891
|
*/
|
1790
|
-
RowFilteringPlugin._overrideConfig = function
|
1791
|
-
|
1792
|
-
|
1793
|
-
|
1794
|
-
|
1795
|
-
|
1796
|
-
|
1797
|
-
|
1798
|
-
|
1799
|
-
|
1800
|
-
|
1801
|
-
|
1802
|
-
|
1803
|
-
|
1804
|
-
|
1805
|
-
|
1806
|
-
|
1807
|
-
|
1808
|
-
|
1809
|
-
|
1810
|
-
|
1811
|
-
|
1812
|
-
|
1813
|
-
|
1814
|
-
|
1815
|
-
|
1816
|
-
|
1817
|
-
|
1818
|
-
|
1819
|
-
|
1820
|
-
|
1821
|
-
|
1822
|
-
|
1823
|
-
|
1824
|
-
|
1825
|
-
|
1826
|
-
|
1827
|
-
|
1828
|
-
|
1829
|
-
|
1830
|
-
|
1831
|
-
|
1832
|
-
|
1833
|
-
|
1834
|
-
|
1835
|
-
|
1836
|
-
|
1837
|
-
|
1838
|
-
|
1839
|
-
|
1840
|
-
|
1892
|
+
RowFilteringPlugin._overrideConfig = function(config, userConfig) {
|
1893
|
+
if(!userConfig) {
|
1894
|
+
return;
|
1895
|
+
}
|
1896
|
+
|
1897
|
+
let sortUI = userConfig["sortUI"];
|
1898
|
+
if(sortUI != null) {
|
1899
|
+
config.sortUI = sortUI;
|
1900
|
+
}
|
1901
|
+
|
1902
|
+
let filterUI = userConfig["filterUI"];
|
1903
|
+
if(filterUI != null) {
|
1904
|
+
config.filterUI = filterUI;
|
1905
|
+
}
|
1906
|
+
|
1907
|
+
let fieldDataType = userConfig["fieldDataType"];
|
1908
|
+
if(fieldDataType != null) {
|
1909
|
+
config.fieldDataType = fieldDataType;
|
1910
|
+
}
|
1911
|
+
|
1912
|
+
let lang = userConfig["lang"];
|
1913
|
+
if(lang != null) {
|
1914
|
+
config.lang = lang;
|
1915
|
+
}
|
1916
|
+
|
1917
|
+
let rawDataAccessor = userConfig["rawDataAccessor"];
|
1918
|
+
if(typeof rawDataAccessor === "function" || rawDataAccessor === null) { // Allow null value
|
1919
|
+
config.rawDataAccessor = rawDataAccessor;
|
1920
|
+
}
|
1921
|
+
|
1922
|
+
let formattedDataAccessor = userConfig["formattedDataAccessor"];
|
1923
|
+
if(typeof formattedDataAccessor === "function" || formattedDataAccessor === null) { // Allow null value
|
1924
|
+
config.formattedDataAccessor = formattedDataAccessor;
|
1925
|
+
}
|
1926
|
+
|
1927
|
+
let sortLogic = userConfig["sortLogic"];
|
1928
|
+
if(typeof sortLogic === "function" || sortLogic === null) { // Allow null value
|
1929
|
+
config.sortLogic = sortLogic;
|
1930
|
+
}
|
1931
|
+
|
1932
|
+
let itemList = userConfig["itemList"];
|
1933
|
+
if(itemList != null) {
|
1934
|
+
config.itemList = itemList;
|
1935
|
+
}
|
1936
|
+
|
1937
|
+
let additionalItems = userConfig["additionalItems"];
|
1938
|
+
if(additionalItems != null) {
|
1939
|
+
config.additionalItems = additionalItems;
|
1940
|
+
}
|
1941
|
+
let blankValues = userConfig["blankValues"];
|
1942
|
+
if(blankValues) {
|
1943
|
+
if(typeof blankValues === "string") {
|
1944
|
+
config.blankValues = blankValues;
|
1945
|
+
} else {
|
1946
|
+
config.blankValues = BLANKS;
|
1947
|
+
}
|
1948
|
+
}
|
1841
1949
|
};
|
1842
1950
|
/** @private
|
1843
1951
|
* @param {number} colIndex
|
1844
1952
|
* @return {Function}
|
1845
1953
|
*/
|
1846
|
-
RowFilteringPlugin.prototype._getFormatter = function
|
1847
|
-
|
1848
|
-
|
1849
|
-
|
1850
|
-
|
1851
|
-
|
1852
|
-
|
1853
|
-
|
1854
|
-
|
1954
|
+
RowFilteringPlugin.prototype._getFormatter = function(colIndex) {
|
1955
|
+
let tfp = this._getPlugin("TextFormattingPlugin");
|
1956
|
+
if(tfp) {
|
1957
|
+
let formatter = tfp.getFormatter(colIndex);
|
1958
|
+
if(formatter) {
|
1959
|
+
return formatter.format || null;
|
1960
|
+
}
|
1961
|
+
}
|
1962
|
+
return null;
|
1855
1963
|
};
|
1856
1964
|
/** @private
|
1857
1965
|
* @return {!FilterBuilder}
|
1858
1966
|
*/
|
1859
|
-
RowFilteringPlugin._getFilterBuilder = function
|
1860
|
-
|
1861
|
-
|
1862
|
-
|
1863
|
-
|
1967
|
+
RowFilteringPlugin._getFilterBuilder = function() {
|
1968
|
+
if(!RowFilteringPlugin._filterBuilder) {
|
1969
|
+
RowFilteringPlugin._filterBuilder = new FilterBuilder();
|
1970
|
+
}
|
1971
|
+
return RowFilteringPlugin._filterBuilder;
|
1864
1972
|
};
|
1865
1973
|
|
1866
1974
|
/** @public
|
1867
1975
|
* @ignore
|
1868
1976
|
* @param {*} val
|
1869
1977
|
*/
|
1870
|
-
RowFilteringPlugin.prototype.mockDialogFilterChange = function
|
1871
|
-
|
1872
|
-
|
1873
|
-
|
1874
|
-
|
1875
|
-
|
1876
|
-
|
1877
|
-
|
1878
|
-
|
1879
|
-
|
1880
|
-
|
1881
|
-
|
1882
|
-
|
1883
|
-
|
1884
|
-
|
1885
|
-
|
1978
|
+
RowFilteringPlugin.prototype.mockDialogFilterChange = function(val) {
|
1979
|
+
if(this._filterDialog) {
|
1980
|
+
let arg = {
|
1981
|
+
detail: {}
|
1982
|
+
};
|
1983
|
+
if(Array.isArray(val)) {
|
1984
|
+
if(Array.isArray(val[0])) {
|
1985
|
+
arg.detail.conditions = val;
|
1986
|
+
} else {
|
1987
|
+
arg.detail.value = val;
|
1988
|
+
}
|
1989
|
+
} else {
|
1990
|
+
arg.detail.value = val;
|
1991
|
+
}
|
1992
|
+
this._onDialogFilterChanged(arg);
|
1993
|
+
}
|
1886
1994
|
};
|
1887
1995
|
/** @private
|
1888
1996
|
* @param {Object} e
|
1889
1997
|
*/
|
1890
|
-
RowFilteringPlugin.prototype._onDialogFilterChanged = function
|
1891
|
-
|
1892
|
-
|
1893
|
-
|
1894
|
-
|
1895
|
-
|
1896
|
-
|
1897
|
-
|
1898
|
-
|
1899
|
-
|
1900
|
-
|
1901
|
-
|
1902
|
-
|
1903
|
-
|
1904
|
-
|
1905
|
-
|
1906
|
-
|
1907
|
-
|
1908
|
-
|
1909
|
-
|
1910
|
-
|
1911
|
-
|
1912
|
-
|
1913
|
-
|
1914
|
-
|
1915
|
-
|
1916
|
-
|
1917
|
-
|
1918
|
-
|
1919
|
-
|
1920
|
-
|
1921
|
-
|
1922
|
-
|
1923
|
-
|
1924
|
-
|
1925
|
-
|
1926
|
-
|
1927
|
-
|
1928
|
-
|
1929
|
-
|
1930
|
-
|
1931
|
-
|
1932
|
-
|
1933
|
-
|
1934
|
-
|
1935
|
-
|
1936
|
-
|
1937
|
-
|
1938
|
-
|
1939
|
-
|
1940
|
-
|
1941
|
-
|
1942
|
-
|
1943
|
-
|
1944
|
-
|
1945
|
-
|
1946
|
-
|
1947
|
-
|
1948
|
-
|
1949
|
-
|
1950
|
-
|
1951
|
-
|
1952
|
-
|
1953
|
-
|
1954
|
-
|
1955
|
-
|
1956
|
-
|
1957
|
-
|
1958
|
-
|
1959
|
-
|
1960
|
-
|
1961
|
-
|
1962
|
-
|
1963
|
-
|
1964
|
-
|
1965
|
-
|
1966
|
-
|
1967
|
-
|
1968
|
-
|
1969
|
-
|
1970
|
-
|
1971
|
-
|
1972
|
-
|
1973
|
-
|
1974
|
-
|
1975
|
-
|
1976
|
-
|
1977
|
-
|
1978
|
-
|
1979
|
-
|
1980
|
-
|
1981
|
-
|
1982
|
-
"colIndex": colIndex
|
1983
|
-
});
|
1998
|
+
RowFilteringPlugin.prototype._onDialogFilterChanged = function(e) {
|
1999
|
+
let colIndex = this._filterDialog._colIndex;
|
2000
|
+
let cfo = this._getColumnFilterOption(colIndex);
|
2001
|
+
let uniqueValues = cfo.uniqueValues; // Unique values have to be stored before the removal of the filter
|
2002
|
+
let rawDataAccessor = cfo._rawDataAccessor;
|
2003
|
+
let formattedDataAccessor = cfo._formattedDataAccessor;
|
2004
|
+
let ctx = null;
|
2005
|
+
if(rawDataAccessor || formattedDataAccessor) {
|
2006
|
+
ctx = {
|
2007
|
+
"rawDataAccessor": rawDataAccessor || null,
|
2008
|
+
"formattedDataAccessor": formattedDataAccessor || null
|
2009
|
+
};
|
2010
|
+
}
|
2011
|
+
this.removeColumnFilters(colIndex);
|
2012
|
+
|
2013
|
+
// Check inputs from advanced filter UIs
|
2014
|
+
let conditions = e.detail.conditions;
|
2015
|
+
if(Array.isArray(conditions)) { // Advanced condition filtering. Expecting 2D-Array
|
2016
|
+
// Ensure rawValue input for number field data type
|
2017
|
+
let condCount = conditions.length;
|
2018
|
+
for(let m = 0; m < condCount; ++m) {
|
2019
|
+
let cond = conditions[m];
|
2020
|
+
let opDef = FilterOperators[cond[0]];
|
2021
|
+
// string type has no need for formatted data or raw data. What is in display is the most important
|
2022
|
+
if(opDef && opDef.type !== "string") {
|
2023
|
+
let inputVal = cond[1]; // inputVal is hardcoded at index 1
|
2024
|
+
let rawValues = uniqueValues[inputVal];
|
2025
|
+
if(rawValues != null) {
|
2026
|
+
cond[1] = rawValues[0];
|
2027
|
+
}
|
2028
|
+
}
|
2029
|
+
}
|
2030
|
+
|
2031
|
+
if(ctx) {
|
2032
|
+
ctx["_autoGenerated"] = true;
|
2033
|
+
}
|
2034
|
+
this.addColumnFilter(colIndex, conditions, ctx);
|
2035
|
+
return;
|
2036
|
+
}
|
2037
|
+
|
2038
|
+
// Check input from free text input
|
2039
|
+
let selVal = e.detail.value;
|
2040
|
+
let selAry = null;
|
2041
|
+
if(selVal) {
|
2042
|
+
if(typeof selVal === "string") { // Custom filter mode (free style text).
|
2043
|
+
// WARNING: Free style text is no longer available anymore from the newer dialog
|
2044
|
+
this.addColumnFilter(colIndex, selVal);
|
2045
|
+
return;
|
2046
|
+
} else {
|
2047
|
+
selAry = /** @type{Array} */(selVal); // Expecting Array of object
|
2048
|
+
}
|
2049
|
+
}
|
2050
|
+
|
2051
|
+
let selCount = selAry ? selAry.length : 0;
|
2052
|
+
if(!selCount) { return; }
|
2053
|
+
|
2054
|
+
// The given input is from simple text filter selector
|
2055
|
+
// Validate if the input is correct and prepare selected items for building filter
|
2056
|
+
let itemMap = {};
|
2057
|
+
let selectedItems = {};
|
2058
|
+
let atLeastOne = false;
|
2059
|
+
for(let i = 0; i < selCount; ++i) {
|
2060
|
+
let formattedVal = selAry[i].title; // title is defined by the multi-select element
|
2061
|
+
// let selIdx = selAry[i].index; // index cannot be used due to filtering
|
2062
|
+
if(selAry[i].value === BLANKS) {
|
2063
|
+
if(!ctx) {
|
2064
|
+
ctx = {};
|
2065
|
+
}
|
2066
|
+
ctx.blankValues = true;
|
2067
|
+
atLeastOne = true;
|
2068
|
+
continue;
|
2069
|
+
}
|
2070
|
+
let rawVals = uniqueValues[formattedVal];
|
2071
|
+
if(!rawVals) {
|
2072
|
+
continue;
|
2073
|
+
}
|
2074
|
+
atLeastOne = true;
|
2075
|
+
selectedItems[formattedVal] = true;
|
2076
|
+
|
2077
|
+
let jLen = rawVals.length;
|
2078
|
+
for(let j = 0; j < jLen; ++j) {
|
2079
|
+
itemMap[rawVals[j]] = true;
|
2080
|
+
}
|
2081
|
+
}
|
2082
|
+
if(atLeastOne) {
|
2083
|
+
this.addColumnFilter(colIndex, itemMap, ctx);
|
2084
|
+
}
|
2085
|
+
this._dispatch("dialogCommitted", {
|
2086
|
+
"value": e.detail.value,
|
2087
|
+
"fieldDataType": e.detail.fieldDataType,
|
2088
|
+
"colIndex": colIndex
|
2089
|
+
});
|
1984
2090
|
};
|
1985
2091
|
|
1986
2092
|
/** @public
|
1987
2093
|
* @ignore
|
1988
2094
|
* @param {string} sortOrder
|
1989
2095
|
*/
|
1990
|
-
RowFilteringPlugin.prototype.mockDialogSortChange = function
|
1991
|
-
|
1992
|
-
|
1993
|
-
|
1994
|
-
|
1995
|
-
|
1996
|
-
|
1997
|
-
|
2096
|
+
RowFilteringPlugin.prototype.mockDialogSortChange = function(sortOrder) {
|
2097
|
+
if(this._filterDialog) {
|
2098
|
+
let arg = {
|
2099
|
+
detail: {}
|
2100
|
+
};
|
2101
|
+
arg.detail.value = sortOrder;
|
2102
|
+
this._onDialogSortChanged(arg);
|
2103
|
+
}
|
1998
2104
|
};
|
1999
2105
|
/** @private
|
2000
2106
|
* @param {Object} e
|
2001
2107
|
*/
|
2002
|
-
RowFilteringPlugin.prototype._onDialogSortChanged = function
|
2003
|
-
|
2004
|
-
|
2005
|
-
|
2006
|
-
|
2007
|
-
|
2008
|
-
|
2009
|
-
|
2010
|
-
|
2011
|
-
|
2012
|
-
|
2013
|
-
|
2014
|
-
|
2015
|
-
|
2016
|
-
|
2108
|
+
RowFilteringPlugin.prototype._onDialogSortChanged = function(e) {
|
2109
|
+
let stp = this._getPlugin("SortableTitlePlugin");
|
2110
|
+
if(stp) {
|
2111
|
+
let colIndex = this._filterDialog._colIndex;
|
2112
|
+
let eDetail = e.detail.value ? e.detail.value : e.detail;
|
2113
|
+
|
2114
|
+
if(stp.getSortOrder(colIndex) === eDetail) {
|
2115
|
+
stp.sortColumn(colIndex, "n");
|
2116
|
+
} else {
|
2117
|
+
stp.sortColumn(colIndex, eDetail);
|
2118
|
+
}
|
2119
|
+
this._dispatch("dialogCommitted", {
|
2120
|
+
"sortOrder": e.detail.value,
|
2121
|
+
"colIndex": colIndex
|
2122
|
+
});
|
2123
|
+
}
|
2017
2124
|
};
|
2018
2125
|
/** @private
|
2019
2126
|
* @param {Object} e
|
2020
2127
|
*/
|
2021
|
-
RowFilteringPlugin.prototype._onColumnAdded = function
|
2022
|
-
|
2023
|
-
|
2024
|
-
|
2025
|
-
|
2026
|
-
|
2027
|
-
|
2128
|
+
RowFilteringPlugin.prototype._onColumnAdded = function(e) {
|
2129
|
+
if(e["context"]) {
|
2130
|
+
let hasFilter = this._setColumnOptions(e["colIndex"], e["context"]);
|
2131
|
+
|
2132
|
+
if(hasFilter) {
|
2133
|
+
this._applyPendingFilter();
|
2134
|
+
}
|
2135
|
+
}
|
2028
2136
|
};
|
2029
2137
|
/** @private
|
2030
2138
|
* @param {Object} e
|
2031
2139
|
*/
|
2032
|
-
RowFilteringPlugin.prototype._onColumnRemoved = function
|
2033
|
-
|
2034
|
-
|
2035
|
-
|
2036
|
-
|
2037
|
-
|
2038
|
-
|
2039
|
-
|
2040
|
-
|
2041
|
-
|
2042
|
-
|
2043
|
-
|
2044
|
-
|
2045
|
-
|
2046
|
-
|
2047
|
-
|
2048
|
-
|
2049
|
-
|
2050
|
-
|
2051
|
-
|
2140
|
+
RowFilteringPlugin.prototype._onColumnRemoved = function(e) {
|
2141
|
+
let colData = /** @type{Object} */(e.columnData);
|
2142
|
+
if(!colData) { return; }
|
2143
|
+
|
2144
|
+
let crf = colData["rowFiltering"];
|
2145
|
+
let cfo = crf["filterOption"];
|
2146
|
+
if(cfo) {
|
2147
|
+
let funcIndex = this._columnFilters.indexOf(cfo);
|
2148
|
+
if(funcIndex >= 0) {
|
2149
|
+
this._columnFilters.splice(funcIndex, 1);
|
2150
|
+
}
|
2151
|
+
|
2152
|
+
this._dispatch("filterChanged", {
|
2153
|
+
"filterType": "column",
|
2154
|
+
"changeType": "remove",
|
2155
|
+
"colIndex": e.colIndex,
|
2156
|
+
"field": cfo._field || ""
|
2157
|
+
});
|
2158
|
+
|
2159
|
+
this._requestFilterRefresh();
|
2160
|
+
}
|
2052
2161
|
};
|
2053
2162
|
|
2054
2163
|
/** the filter will automatically hide empty segment when all of its member are filtered out. If there is no active filter, any empty segment will not be hidden. Collapsed segment does not count as having a filter. A segment with no child is treated the same way as an empty segment.
|
@@ -2056,22 +2165,25 @@ RowFilteringPlugin.prototype._onColumnRemoved = function (e) {
|
|
2056
2165
|
* @param {boolean=} enabled=true
|
2057
2166
|
*/
|
2058
2167
|
RowFilteringPlugin.prototype.enableEmptySegmentFiltering = function (enabled) {
|
2059
|
-
|
2060
|
-
|
2061
|
-
|
2062
|
-
|
2063
|
-
|
2168
|
+
let host = this._hosts[0];
|
2169
|
+
let dv = host ? host.getDataSource() : null;
|
2170
|
+
if(dv && dv.enableEmptySegmentFiltering) {
|
2171
|
+
dv.enableEmptySegmentFiltering(enabled);
|
2172
|
+
}
|
2064
2173
|
};
|
2065
2174
|
/** the filter will automatically hide empty segment when all of its member are filtered out. If there is no active filter, any empty segment will not be hidden. Collapsed segment does not count as having a filter.
|
2066
2175
|
* @public
|
2067
2176
|
* @param {boolean=} enabled=true
|
2068
2177
|
*/
|
2069
2178
|
RowFilteringPlugin.prototype.enableSeparatorFiltering = function (enabled) {
|
2070
|
-
|
2071
|
-
|
2072
|
-
|
2073
|
-
|
2074
|
-
|
2179
|
+
let host = this._hosts[0];
|
2180
|
+
let dv = host ? host.getDataSource() : null;
|
2181
|
+
if(dv && dv.enableSeparatorFiltering) {
|
2182
|
+
dv.enableSeparatorFiltering(enabled);
|
2183
|
+
}
|
2075
2184
|
};
|
2185
|
+
|
2186
|
+
|
2187
|
+
|
2076
2188
|
export default RowFilteringPlugin;
|
2077
|
-
export { RowFilteringPlugin, RowFilteringPlugin as RowFiltering, RowFilteringPlugin as RowFilteringExtension };
|
2189
|
+
export { RowFilteringPlugin, RowFilteringPlugin as RowFiltering, RowFilteringPlugin as RowFilteringExtension };
|