-
-
Notifications
You must be signed in to change notification settings - Fork 119
/
grid-contextmenu.component.ts
672 lines (634 loc) · 26 KB
/
grid-contextmenu.component.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
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
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
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
431
432
433
434
435
436
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
499
500
501
502
503
504
505
506
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
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
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
618
619
620
621
622
623
624
625
626
627
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
import { Component, OnInit, OnDestroy, ViewEncapsulation } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { ExcelExportService } from '@slickgrid-universal/excel-export';
import { Subscription } from 'rxjs';
import {
AngularGridInstance,
Column,
ContextMenu,
ExtensionName,
FieldType,
Filters,
Formatter,
Formatters,
GridOption,
unsubscribeAllObservables,
} from './../modules/angular-slickgrid';
const actionFormatter: Formatter = (_row, _cell, _value, _columnDef, dataContext) => {
if (dataContext.priority === 3) {
// option 3 is High
return `<div class="cell-menu-dropdown-outline">Action<i class="mdi mdi-chevron-down"></i></div>`;
}
return `<div class="cell-menu-dropdown-outline disabled">Action <i class="mdi mdi-chevron-down"></i></div>`;
};
const priorityFormatter: Formatter = (_row, _cell, value) => {
if (!value) {
return '';
}
let output = '';
const count = +(value >= 3 ? 3 : value);
const color = count === 3 ? 'red' : count === 2 ? 'orange' : 'yellow';
const icon = `<i class="mdi mdi-star ${color}" aria-hidden="true"></i>`;
for (let i = 1; i <= count; i++) {
output += icon;
}
return output;
};
const priorityExportFormatter: Formatter = (row, cell, value, columnDef, dataContext, grid) => {
if (!value) {
return '';
}
const gridOptions = grid.getOptions() as GridOption;
const translate = gridOptions.i18n;
const count = +(value >= 3 ? 3 : value);
const key = count === 3 ? 'HIGH' : count === 2 ? 'MEDIUM' : 'LOW';
return translate && translate.instant && translate.instant(key);
};
const taskTranslateFormatter: Formatter = (row, cell, value, columnDef, dataContext, grid) => {
const gridOptions = grid.getOptions() as GridOption;
const translate = gridOptions.i18n;
return translate && translate.instant && translate.instant('TASK_X', { x: value });
};
@Component({
templateUrl: './grid-contextmenu.component.html',
styleUrls: ['./grid-contextmenu.component.scss'],
encapsulation: ViewEncapsulation.None,
})
export class GridContextMenuComponent implements OnInit, OnDestroy {
title = 'Example 26: Cell Menu & Context Menu Plugins';
subTitle = `Add Cell Menu and Context Menu
<ul>
<li>This example demonstrates 2 SlickGrid plugins</li>
<ol>
<li>Using the <b>Slick.Plugins.CellMenu</b> plugin, often used for an Action Menu(s), 1 or more per grid
(<a href="https://ghiscoding.gitbook.io/angular-slickgrid/grid-functionalities/cell-menu" target="_blank">Wiki docs</a>).
</li>
<li>Using the <b>Slick.Plugins.ContextMenu</b> plugin, shown after a mouse right+click, only 1 per grid.
(<a href="https://ghiscoding.gitbook.io/angular-slickgrid/grid-functionalities/context-menu" target="_blank">Wiki docs</a>).
</li>
</ol>
<li>It will also "autoAdjustDrop" (bottom/top) and "autoAlignSide" (left/right) by default but could be turned off</li>
<li>Both plugins have 2 sections, 1st section can have an array of Options (to change value of a field) and 2nd section an array of Commands (execute a command)</li>
<li>There are 2 ways to execute a Command/Option</li>
<ol>
<li>via onCommand/onOptionSelected (use a switch/case to parse command/option and do something with it)</li>
<li>via action callback (that can be defined on each command/option)</li>
</ol>
<li>Use override callback functions to change the properties of show/hide, enable/disable the menu or certain item(s) from the list</li>
<ol>
<li>These callbacks are: "menuUsabilityOverride", "itemVisibilityOverride", "itemUsabilityOverride"</li>
<li>... e.g. in the demo, the "Action" Cell Menu is only available when Priority is set to "High" via "menuUsabilityOverride"</li>
<li>... e.g. in the demo, the Context Menu is only available on the first 20 Tasks via "menuUsabilityOverride"</li>
</ol>
</ul>`;
private _darkModeGrid = false;
private subscriptions: Subscription[] = [];
angularGrid!: AngularGridInstance;
columnDefinitions!: Column[];
gridOptions!: GridOption;
dataset!: any[];
selectedLanguage: string;
constructor(private translate: TranslateService) {
// always start with English for Cypress E2E tests to be consistent
const defaultLang = 'en';
this.translate.use(defaultLang);
this.selectedLanguage = defaultLang;
}
angularGridReady(angularGrid: AngularGridInstance) {
this.angularGrid = angularGrid;
}
get cellMenuInstance() {
return this.angularGrid?.extensionService?.getExtensionInstanceByName(ExtensionName.cellMenu);
}
get contextMenuInstance() {
return this.angularGrid?.extensionService?.getExtensionInstanceByName(ExtensionName.contextMenu);
}
ngOnInit() {
this.prepareGrid();
this.dataset = this.getData(1000);
}
ngOnDestroy() {
// also unsubscribe all Angular Subscriptions
unsubscribeAllObservables(this.subscriptions);
document.querySelector('.panel-wm-content')!.classList.remove('dark-mode');
document.querySelector<HTMLDivElement>('#demo-container')!.dataset.bsTheme = 'light';
}
prepareGrid() {
this.columnDefinitions = [
{ id: 'id', name: '#', field: 'id', maxWidth: 45, sortable: true, filterable: true },
{
id: 'title',
name: 'Title',
field: 'id',
nameKey: 'TITLE',
minWidth: 100,
formatter: taskTranslateFormatter,
sortable: true,
filterable: true,
params: { useFormatterOuputToFilter: true },
},
{
id: 'percentComplete',
nameKey: 'PERCENT_COMPLETE',
field: 'percentComplete',
minWidth: 100,
exportWithFormatter: false,
sortable: true,
filterable: true,
filter: { model: Filters.slider, operator: '>=' },
formatter: Formatters.percentCompleteBar,
type: FieldType.number,
},
{
id: 'start',
name: 'Start',
field: 'start',
nameKey: 'START',
minWidth: 100,
formatter: Formatters.dateIso,
outputType: FieldType.dateIso,
type: FieldType.date,
filterable: true,
filter: { model: Filters.compoundDate },
},
{
id: 'finish',
name: 'Finish',
field: 'finish',
nameKey: 'FINISH',
formatter: Formatters.dateIso,
outputType: FieldType.dateIso,
type: FieldType.date,
minWidth: 100,
filterable: true,
filter: { model: Filters.compoundDate },
},
{
id: 'priority',
nameKey: 'PRIORITY',
field: 'priority',
exportCustomFormatter: priorityExportFormatter,
formatter: priorityFormatter,
sortable: true,
filterable: true,
filter: {
collection: [
{ value: '', label: '' },
{ value: 1, labelKey: 'LOW' },
{ value: 2, labelKey: 'MEDIUM' },
{ value: 3, labelKey: 'HIGH' },
],
model: Filters.singleSelect,
enableTranslateLabel: true,
},
},
{
id: 'completed',
nameKey: 'COMPLETED',
field: 'completed',
exportCustomFormatter: Formatters.translateBoolean,
formatter: Formatters.checkmarkMaterial,
sortable: true,
filterable: true,
filter: {
collection: [
{ value: '', label: '' },
{ value: true, labelKey: 'TRUE' },
{ value: false, labelKey: 'FALSE' },
],
model: Filters.singleSelect,
enableTranslateLabel: true,
},
},
{
id: 'action',
name: 'Action',
field: 'action',
width: 100,
maxWidth: 110,
excludeFromExport: true,
formatter: actionFormatter,
cellMenu: {
hideCloseButton: false,
// you can override the logic of when the menu is usable
// for example say that we want to show a menu only when then Priority is set to 'High'.
// Note that this ONLY overrides the usability itself NOT the text displayed in the cell,
// if you wish to change the cell text (or hide it)
// then you SHOULD use it in combination with a custom formatter (actionFormatter) and use the same logic in that formatter
menuUsabilityOverride: (args) => {
return args.dataContext.priority === 3; // option 3 is High
},
// when using Translate Service, every translation will have the suffix "Key"
// else use title without the suffix, for example "commandTitle" (no translations) or "commandTitleKey" (with translations)
commandTitleKey: 'COMMANDS', // optional title, use "commandTitle" when not using Translate
commandItems: [
// array of command item objects, you can also use the "positionOrder" that will be used to sort the items in the list
{
command: 'command2',
title: 'Command 2',
positionOrder: 62,
// you can use the "action" callback and/or use "onCallback" callback from the grid options, they both have the same arguments
action: (e, args) => {
console.log(args.dataContext, args.column);
// action callback.. do something
},
// only enable command when the task is not completed
itemUsabilityOverride: (args) => {
return !args.dataContext.completed;
},
},
{ command: 'command1', title: 'Command 1', cssClass: 'orange', positionOrder: 61 },
{
command: 'delete-row',
titleKey: 'DELETE_ROW',
positionOrder: 64,
iconCssClass: 'mdi mdi-close',
cssClass: 'red',
textCssClass: 'bold',
// only show command to 'Delete Row' when the task is not completed
itemVisibilityOverride: (args) => {
return !args.dataContext.completed;
},
},
// you can pass divider as a string or an object with a boolean (if sorting by position, then use the object)
// note you should use the "divider" string only when items array is already sorted and positionOrder are not specified
{ divider: true, command: '', positionOrder: 63 },
// 'divider',
{
command: 'help',
titleKey: 'HELP', // use "title" without translation and "titleKey" with TranslateService
iconCssClass: 'mdi mdi-help-circle',
positionOrder: 66,
},
{ command: 'something', titleKey: 'DISABLED_COMMAND', disabled: true, positionOrder: 67 },
{ command: '', divider: true, positionOrder: 98 },
{
// we can also have multiple nested sub-menus
command: 'export',
title: 'Exports',
positionOrder: 99,
commandItems: [
{ command: 'exports-txt', title: 'Text (tab delimited)' },
{
command: 'sub-menu',
title: 'Excel',
cssClass: 'green',
subMenuTitle: 'available formats',
subMenuTitleCssClass: 'text-italic orange',
commandItems: [
{ command: 'exports-csv', title: 'Excel (csv)' },
{ command: 'exports-xlsx', title: 'Excel (xlsx)' },
],
},
],
},
{
command: 'feedback',
title: 'Feedback',
positionOrder: 100,
commandItems: [
{
command: 'request-update',
title: 'Request update from supplier',
iconCssClass: 'mdi mdi-star',
tooltip: 'this will automatically send an alert to the shipping team to contact the user for an update',
},
'divider',
{
command: 'sub-menu',
title: 'Contact Us',
iconCssClass: 'mdi mdi-account',
subMenuTitle: 'contact us...',
subMenuTitleCssClass: 'italic',
commandItems: [
{ command: 'contact-email', title: 'Email us', iconCssClass: 'mdi mdi-pencil-outline' },
{ command: 'contact-chat', title: 'Chat with us', iconCssClass: 'mdi mdi-message-text-outline' },
{ command: 'contact-meeting', title: 'Book an appointment', iconCssClass: 'mdi mdi-coffee' },
],
},
],
},
],
optionTitleKey: 'CHANGE_COMPLETED_FLAG',
optionItems: [
{ option: true, titleKey: 'TRUE', iconCssClass: 'mdi mdi-check-box-outline' },
{ option: false, titleKey: 'FALSE', iconCssClass: 'mdi mdi-checkbox-blank-outline' },
{
option: null,
title: 'null',
cssClass: 'italic',
// you can use the "action" callback and/or use "onCallback" callback from the grid options, they both have the same arguments
action: (_e, _args) => {
// action callback.. do something
},
// only enable Action menu when the Priority is set to High
itemUsabilityOverride: (args) => {
return args.dataContext.priority === 3;
},
// only show command to 'Delete Row' when the task is not completed
itemVisibilityOverride: (args) => {
return !args.dataContext.completed;
},
},
],
},
},
];
this.gridOptions = {
autoResize: {
container: '#demo-container',
rightPadding: 10,
},
darkMode: this._darkModeGrid,
enableCellNavigation: true,
enableFiltering: true,
enableSorting: true,
enableTranslate: true,
enableExcelExport: true,
excelExportOptions: {
exportWithFormatter: true,
customColumnWidth: 15,
// you can customize how the header titles will be styled (defaults to Bold)
columnHeaderStyle: { font: { bold: true, italic: true } },
},
i18n: this.translate,
externalResources: [new ExcelExportService()],
enableContextMenu: true,
enableCellMenu: true,
// when using the cellMenu, you can change some of the default options and all use some of the callback methods
cellMenu: {
// all the Cell Menu callback methods (except the action callback)
// are available under the grid options as shown below
onCommand: (e, args) => this.executeCommand(e, args),
onOptionSelected: (e, args) => {
// change "Completed" property with new option selected from the Cell Menu
const dataContext = args && args.dataContext;
if (dataContext && 'completed' in dataContext) {
dataContext.completed = args.item.option;
this.angularGrid.gridService.updateItem(dataContext);
}
},
onBeforeMenuShow: (e, args) => {
// for example, you could select the row that the click originated
// this.angularGrid.gridService.setSelectedRows([args.row]);
console.log('Before the Cell Menu is shown', args);
},
onBeforeMenuClose: (e, args) => console.log('Cell Menu is closing', args),
},
// load Context Menu structure
contextMenu: this.getContextMenuOptions(),
};
}
executeCommand(_e: any, args: any) {
// const columnDef = args.column;
const command = args.command;
const dataContext = args.dataContext;
switch (command) {
case 'contact-email':
case 'contact-chat':
case 'contact-meeting':
alert('Command: ' + args?.command);
break;
case 'exports-csv':
case 'exports-txt':
case 'exports-xlsx':
alert(`Exporting as ${args.item.title}`);
break;
case 'command1':
alert('Command 1');
break;
case 'command2':
alert('Command 2');
break;
case 'help':
alert('Please help!');
break;
case 'delete-row':
if (
confirm(
`Do you really want to delete row ${args.row + 1} with ${this.translate.instant('TASK_X', { x: dataContext.id })}`
)
) {
this.angularGrid.dataView.deleteItem(dataContext.id);
}
break;
}
}
getData(count: number) {
// mock a dataset
const tmpData = [];
for (let i = 0; i < count; i++) {
const randomYear = 2000 + Math.floor(Math.random() * 30);
const randomMonth = Math.floor(Math.random() * 11);
const randomDay = Math.floor(Math.random() * 29);
tmpData[i] = {
id: i,
duration: Math.floor(Math.random() * 25) + ' days',
percentComplete: Math.floor(Math.random() * 100),
start: new Date(randomYear, randomMonth, randomDay),
finish: new Date(randomYear, randomMonth + 1, randomDay),
priority: i % 3 ? 2 : i % 5 ? 3 : 1,
completed: i % 4 === 0,
};
}
return tmpData;
}
getContextMenuOptions(): ContextMenu {
return {
hideCloseButton: false,
// optionally and conditionally define when the the menu is usable,
// this should be used with a custom formatter to show/hide/disable the menu
menuUsabilityOverride: (args) => {
const dataContext = args && args.dataContext;
return dataContext.id < 21; // say we want to display the menu only from Task 0 to 20
},
// which column to show the command list? when not defined it will be shown over all columns
commandShownOverColumnIds: ['id', 'title', 'percentComplete', 'start', 'finish', 'completed' /*, 'priority', 'action' */],
commandTitleKey: 'COMMANDS', // this title is optional, you could also use "commandTitle" when not using Translate
commandItems: [
{ divider: true, command: '', positionOrder: 61 },
{
command: 'delete-row',
titleKey: 'DELETE_ROW',
iconCssClass: 'mdi mdi-close',
cssClass: 'red',
textCssClass: 'bold',
positionOrder: 62,
},
// you can pass divider as a string or an object with a boolean (if sorting by position, then use the object)
// note you should use the "divider" string only when items array is already sorted and positionOrder are not specified
// 'divider',
{ divider: true, command: '', positionOrder: 63 },
{
command: 'help',
titleKey: 'HELP',
iconCssClass: 'mdi mdi-help-circle',
positionOrder: 64,
// you can use the 'action' callback and/or subscribe to the 'onCallback' event, they both have the same arguments
action: (_e, _args) => {
// action callback.. do something
},
// only show command to 'Help' when the task is Not Completed
itemVisibilityOverride: (args) => {
const dataContext = args && args.dataContext;
return !dataContext.completed;
},
},
{ command: 'something', titleKey: 'DISABLED_COMMAND', disabled: true, positionOrder: 65 },
{ command: '', divider: true, positionOrder: 98 },
{
// we can also have multiple nested sub-menus
command: 'export',
title: 'Exports',
positionOrder: 99,
commandItems: [
{ command: 'exports-txt', title: 'Text (tab delimited)' },
{
command: 'sub-menu',
title: 'Excel',
cssClass: 'green',
subMenuTitle: 'available formats',
subMenuTitleCssClass: 'text-italic orange',
commandItems: [
{ command: 'exports-csv', title: 'Excel (csv)' },
{ command: 'exports-xlsx', title: 'Excel (xlsx)' },
],
},
],
},
{
command: 'feedback',
title: 'Feedback',
positionOrder: 100,
commandItems: [
{
command: 'request-update',
title: 'Request update from supplier',
iconCssClass: 'mdi mdi-star',
tooltip: 'this will automatically send an alert to the shipping team to contact the user for an update',
},
'divider',
{
command: 'sub-menu',
title: 'Contact Us',
iconCssClass: 'mdi mdi-account',
subMenuTitle: 'contact us...',
subMenuTitleCssClass: 'italic',
commandItems: [
{ command: 'contact-email', title: 'Email us', iconCssClass: 'mdi mdi-pencil-outline' },
{ command: 'contact-chat', title: 'Chat with us', iconCssClass: 'mdi mdi-message-text-outline' },
{ command: 'contact-meeting', title: 'Book an appointment', iconCssClass: 'mdi mdi-coffee' },
],
},
],
},
],
// Options allows you to edit a column from an option chose a list
// for example, changing the Priority value
// you can also optionally define an array of column ids that you wish to display this option list (when not defined it will show over all columns)
optionTitleKey: 'CHANGE_PRIORITY',
optionShownOverColumnIds: ['priority'], // optional, when defined it will only show over the columns (column id) defined in the array
optionItems: [
{
option: 0,
title: 'n/a',
textCssClass: 'italic',
// only enable this option when the task is Not Completed
itemUsabilityOverride: (args) => {
const dataContext = args && args.dataContext;
return !dataContext.completed;
},
// you can use the 'action' callback and/or subscribe to the 'onCallback' event, they both have the same arguments
action: (_e, _args) => {
// action callback.. do something
},
},
{ option: 1, iconCssClass: 'mdi mdi-star-outline yellow', titleKey: 'LOW' },
{ option: 2, iconCssClass: 'mdi mdi-star orange', titleKey: 'MEDIUM' },
{ option: 3, iconCssClass: 'mdi mdi-star red', titleKey: 'HIGH' },
// you can pass divider as a string or an object with a boolean (if sorting by position, then use the object)
// note you should use the "divider" string only when items array is already sorted and positionOrder are not specified
'divider',
// { divider: true, option: '', positionOrder: 3 },
{
option: 4,
title: 'Extreme',
iconCssClass: 'mdi mdi-fire',
disabled: true,
// only shown when the task is Not Completed
itemVisibilityOverride: (args) => {
const dataContext = args && args.dataContext;
return !dataContext.completed;
},
},
{
// we can also have multiple nested sub-menus
option: null,
title: 'Sub-Options (demo)',
subMenuTitleKey: 'CHANGE_PRIORITY',
optionItems: [
{ option: 1, iconCssClass: 'mdi mdi-star-outline yellow', titleKey: 'LOW' },
{ option: 2, iconCssClass: 'mdi mdi-star orange', titleKey: 'MEDIUM' },
{ option: 3, iconCssClass: 'mdi mdi-star red', titleKey: 'HIGH' },
],
},
],
// subscribe to Context Menu
onBeforeMenuShow: (e, args) => {
// for example, you could select the row it was clicked with
// grid.setSelectedRows([args.row]); // select the entire row
this.angularGrid.slickGrid.setActiveCell(args.row, args.cell, false); // select the cell that the click originated
console.log('Before the global Context Menu is shown', args);
},
onBeforeMenuClose: (e, args) => console.log('Global Context Menu is closing', args),
// subscribe to Context Menu onCommand event (or use the action callback on each command)
onCommand: (e, args) => this.executeCommand(e, args),
// subscribe to Context Menu onOptionSelected event (or use the action callback on each option)
onOptionSelected: (e, args) => {
// change Priority
const dataContext = args && args.dataContext;
if (dataContext && 'priority' in dataContext) {
dataContext.priority = args.item.option;
this.angularGrid.gridService.updateItem(dataContext);
}
},
};
}
showContextCommandsAndOptions(showBothList: boolean) {
// when showing both Commands/Options, we can just pass an empty array to show over all columns
// else show on all columns except Priority
const showOverColumnIds = showBothList ? [] : ['id', 'title', 'complete', 'start', 'finish', 'completed', 'action'];
this.contextMenuInstance?.setOptions({
commandShownOverColumnIds: showOverColumnIds,
// hideCommandSection: !showBothList
});
}
showCellMenuCommandsAndOptions(showBothList: boolean) {
// change via the plugin setOptions
this.cellMenuInstance?.setOptions({
hideOptionSection: !showBothList,
});
// OR find the column, then change the same hide property
// var actionColumn = columns.find(function (column) { return column.id === 'action' });
// actionColumn.cellMenu.hideOptionSection = !showBothList;
}
switchLanguage() {
const nextLanguage = this.selectedLanguage === 'en' ? 'fr' : 'en';
this.subscriptions.push(
this.translate.use(nextLanguage).subscribe(() => {
this.selectedLanguage = nextLanguage;
})
);
}
toggleDarkMode() {
this._darkModeGrid = !this._darkModeGrid;
if (this._darkModeGrid) {
document.querySelector<HTMLDivElement>('.panel-wm-content')!.classList.add('dark-mode');
document.querySelector<HTMLDivElement>('#demo-container')!.dataset.bsTheme = 'dark';
} else {
document.querySelector('.panel-wm-content')!.classList.remove('dark-mode');
document.querySelector<HTMLDivElement>('#demo-container')!.dataset.bsTheme = 'light';
}
this.angularGrid.slickGrid?.setOptions({ darkMode: this._darkModeGrid });
}
}