Skip to content
This repository was archived by the owner on Jun 1, 2025. It is now read-only.

Commit 2046af4

Browse files
Ghislain BeaulacGhislain Beaulac
authored andcommitted
feat(ColPicker/GridMenu): expose new hide flags and onColumnsChanged
1 parent e1f0dde commit 2046af4

File tree

5 files changed

+87
-3
lines changed

5 files changed

+87
-3
lines changed

src/app/examples/grid-menu.component.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,13 @@ export class GridMenuComponent implements OnInit {
5757
this.visibleColumns = this.columnDefinitions;
5858

5959
this.gridOptions = {
60+
columnPicker: {
61+
hideForceFitButton: true,
62+
hideSyncResizeButton: true,
63+
onColumnsChanged: (e, args) => {
64+
console.log('Column selection changed from Column Picker, visible columns: ', args.columns);
65+
}
66+
},
6067
enableAutoResize: true,
6168
enableGridMenu: true,
6269
autoResize: {
@@ -69,6 +76,8 @@ export class GridMenuComponent implements OnInit {
6976
customTitle: 'Custom Commands',
7077
columnTitle: 'Columns',
7178
iconCssClass: 'fa fa-ellipsis-v',
79+
hideForceFitButton: true,
80+
hideSyncResizeButton: true,
7281
menuWidth: 17,
7382
resizeOnShowHeaderRow: true,
7483
customItems: [
@@ -118,6 +127,9 @@ export class GridMenuComponent implements OnInit {
118127
} else {
119128
alert('Command: ' + args.command);
120129
}
130+
},
131+
onColumnsChanged: (e, args) => {
132+
console.log('Column selection changed from Grid Menu, visible columns: ', args.columns);
121133
}
122134
},
123135
};

src/app/modules/angular-slickgrid/global-grid-options.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ export const GlobalGridOptions: GridOption = {
1717
checkboxSelector: {
1818
cssClass: 'slick-cell-checkboxsel'
1919
},
20+
columnPicker: {
21+
hideForceFitButton: false,
22+
hideSyncResizeButton: true
23+
},
2024
editable: false,
2125
enableAutoResize: true,
2226
enableCellNavigation: false,
@@ -31,6 +35,8 @@ export const GlobalGridOptions: GridOption = {
3135
exportWithFormatter: false,
3236
forceFitColumns: false,
3337
gridMenu: {
38+
hideForceFitButton: false,
39+
hideSyncResizeButton: true,
3440
iconCssClass: 'fa fa-bars',
3541
menuWidth: 16,
3642
resizeOnShowHeaderRow: false,
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
export interface ColumnPicker {
2+
/** Defaults to "Columns" which is the title that shows up over the columns */
23
columnTitle?: string;
4+
5+
/** Defaults to "Force fit columns" which is 1 of the last 2 checkbox title shown at the end of the picker list */
36
forceFitTitle?: string;
7+
8+
/** Defaults to True, show/hide 1 of the last 2 checkbox at the end of the picker list */
9+
hideForceFitButton?: boolean;
10+
11+
/** Defaults to True, show/hide 1 of the last 2 checkbox at the end of the picker list */
12+
hideSyncResizeButton?: boolean;
13+
14+
/** Defaults to "Synchronous resize" which is 1 of the last 2 checkbox title shown at the end of the picker list */
415
syncResizeTitle?: string;
16+
17+
/** SlickGrid Event fired when any of the columns checkbox selection changes. */
18+
onColumnsChanged?: (e: Event, args: any) => void;
519
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,66 @@
11
import { CustomGridMenu } from './customGridMenu.interface';
22

33
export interface GridMenu {
4+
/** Array of Custom Items (title, command, disabled, ...) */
45
customItems?: CustomGridMenu[];
6+
7+
/** Defaults to "Commands" which is the title that shows up over the custom commands list */
58
customTitle?: string;
9+
10+
/** Defaults to "Columns" which is the title that shows up over the columns */
611
columnTitle?: string;
12+
13+
/** Link for the displaying the Grid menu icon image (basically the hamburger menu) */
714
iconImage?: string;
15+
16+
/** CSS class for the displaying the Grid menu icon image (basically the hamburger menu) */
817
iconCssClass?: string;
18+
19+
/** Defaults to False, which leads to leaving the menu open after a click */
920
leaveOpen?: boolean;
21+
22+
/** Defaults to 16 pixels (only the number), which is the width in pixels of the Grid Menu icon */
1023
menuWidth?: number;
24+
25+
/** Defaults to "Force fit columns" which is 1 of the last 2 checkbox title shown at the end of the picker list */
1126
forceFitTitle?: string;
27+
28+
/** Defaults to True, show/hide 1 of the last 2 checkbox at the end of the picker list */
29+
hideForceFitButton?: boolean;
30+
31+
/** Defaults to True, show/hide 1 of the last 2 checkbox at the end of the picker list */
32+
hideSyncResizeButton?: boolean;
33+
34+
/** Defaults to False, which will resize the Header Row and remove the width of the Grid Menu icon from it's total width. */
1235
resizeOnShowHeaderRow?: boolean;
36+
37+
/** Defaults to True, which will show the "Clear All Filter" command in the Grid Menu (Grid Option "enableFiltering: true" has to be enabled) */
1338
showClearAllFiltersCommand?: boolean;
39+
40+
/** Defaults to True, which will show the "Export to CSV" command in the Grid Menu (Grid Option "enableExport: true" has to be enabled) */
1441
showExportCsvCommand?: boolean;
42+
43+
/** Defaults to True, which will show the "Export to Text Delimited" command in the Grid Menu (Grid Option "enableExport: true" has to be enabled) */
1544
showExportTextDelimitedCommand?: boolean;
45+
46+
/** Defaults to True, which will show the "Refresh Dataset" command in the Grid Menu (only works with a Backend Service API) */
1647
showRefreshDatasetCommand?: boolean;
48+
49+
/** Defaults to True, which will show the "Toggle Filter Row" command in the Grid Menu (Grid Option "enableFiltering: true" has to be enabled) */
1750
showToggleFilterCommand?: boolean;
51+
52+
/** Defaults to "Synchronous resize" which is 1 of the last 2 checkbox title shown at the end of the picker list */
1853
syncResizeTitle?: string;
1954

55+
/** SlickGrid Event fired before the menu is shown. */
2056
onBeforeMenuShow?: (e: Event, args: any) => void;
57+
58+
/** SlickGrid Event fired when any of the columns checkbox selection changes. */
59+
onColumnsChanged?: (e: Event, args: any) => void;
60+
61+
/** SlickGrid Event fired when the menu is closing. */
2162
onMenuClose?: (e: Event, args: any) => void;
63+
64+
/** SlickGrid Event fired on menu item click for buttons with 'command' specified. */
2265
onCommand?: (e: Event, args: any) => void;
2366
}

src/app/modules/angular-slickgrid/services/controlAndPlugin.service.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,13 @@ export class ControlAndPluginService {
125125
options.columnPicker.syncResizeTitle = options.columnPicker.syncResizeTitle || syncResizeTitle;
126126

127127
this.columnPickerControl = new Slick.Controls.ColumnPicker(columnDefinitions, grid, options);
128+
if (grid && options.enableColumnPicker) {
129+
this.columnPickerControl.onColumnsChanged.subscribe((e: Event, args: CellArgs) => {
130+
if (options.columnPicker && typeof options.columnPicker.onColumnsChanged === 'function') {
131+
options.columnPicker.onColumnsChanged(e, args);
132+
}
133+
});
134+
}
128135
}
129136

130137
/**
@@ -144,6 +151,11 @@ export class ControlAndPluginService {
144151
options.gridMenu.onBeforeMenuShow(e, args);
145152
}
146153
});
154+
gridMenuControl.onColumnsChanged.subscribe((e: Event, args: CellArgs) => {
155+
if (options.gridMenu && typeof options.gridMenu.onColumnsChanged === 'function') {
156+
options.gridMenu.onColumnsChanged(e, args);
157+
}
158+
});
147159
gridMenuControl.onCommand.subscribe((e: Event, args: CellArgs) => {
148160
if (options.gridMenu && typeof options.gridMenu.onCommand === 'function') {
149161
options.gridMenu.onCommand(e, args);
@@ -195,9 +207,6 @@ export class ControlAndPluginService {
195207
this.columnPickerControl = null;
196208
}
197209
if (this.gridMenuControl) {
198-
this.gridMenuControl.onBeforeMenuShow.unsubscribe();
199-
this.gridMenuControl.onCommand.unsubscribe();
200-
this.gridMenuControl.onMenuClose.unsubscribe();
201210
this.gridMenuControl.destroy();
202211
this.gridMenuControl = null;
203212
}

0 commit comments

Comments
 (0)