-
-
Notifications
You must be signed in to change notification settings - Fork 120
/
Copy pathglobal-grid-options.ts
274 lines (272 loc) · 9.32 KB
/
global-grid-options.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
import {
type Column,
DelimiterType,
EventNamingStyle,
FileType,
Filters,
type GridOption as GridOptionUniversal,
OperatorType,
type TreeDataOption,
} from '@slickgrid-universal/common';
import type { GridOption, RowDetailView } from './models/index';
/** Global Grid Options Defaults */
export const GlobalGridOptions: Partial<GridOption> = {
alwaysShowVerticalScroll: true,
autoEdit: false,
asyncEditorLoading: false,
autoFitColumnsOnFirstLoad: true,
autoResize: {
applyResizeToContainer: true,
autoHeight: true,
autoHeightRecalcRow: 100,
calculateAvailableSizeBy: 'window',
bottomPadding: 20,
minHeight: 250,
minWidth: 300,
rightPadding: 0,
},
cellHighlightCssClass: 'slick-cell-modified',
checkboxSelector: {
cssClass: 'slick-cell-checkboxsel',
},
columnPicker: {
hideForceFitButton: false,
hideSyncResizeButton: true,
headerColumnValueExtractor: pickerHeaderColumnValueExtractor,
},
cellMenu: {
autoAdjustDrop: true,
autoAlignSide: true,
hideCloseButton: true,
hideCommandSection: false,
hideOptionSection: false,
},
contextMenu: {
autoAdjustDrop: true,
autoAlignSide: true,
hideCloseButton: true,
hideClearAllGrouping: false,
hideCollapseAllGroups: false,
hideCommandSection: false,
hideCopyCellValueCommand: false,
hideExpandAllGroups: false,
hideExportCsvCommand: false,
hideExportExcelCommand: false,
hideExportTextDelimitedCommand: true,
hideMenuOnScroll: true,
hideOptionSection: false,
iconCollapseAllGroupsCommand: 'mdi mdi-arrow-collapse',
iconExpandAllGroupsCommand: 'mdi mdi-arrow-expand',
iconClearGroupingCommand: 'mdi mdi-close',
iconCopyCellValueCommand: 'mdi mdi-content-copy',
iconExportCsvCommand: 'mdi mdi-download',
iconExportExcelCommand: 'mdi mdi-file-excel-outline',
iconExportTextDelimitedCommand: 'mdi mdi-download',
showBulletWhenIconMissing: true,
subItemChevronClass: 'mdi mdi-chevron-down mdi-rotate-270',
},
customFooterOptions: {
dateFormat: 'YYYY-MM-DD, hh:mm a',
hideRowSelectionCount: false,
hideTotalItemCount: false,
hideLastUpdateTimestamp: true,
footerHeight: 25,
leftContainerClass: 'col-xs-12 col-sm-5',
rightContainerClass: 'col-xs-6 col-sm-7',
metricSeparator: '|',
metricTexts: {
items: 'items',
itemsKey: 'ITEMS',
itemsSelected: 'items selected',
itemsSelectedKey: 'ITEMS_SELECTED',
of: 'of',
ofKey: 'OF',
},
},
dataView: {
// when enabled, this will preserve the row selection even after filtering/sorting/grouping
syncGridSelection: {
preserveHidden: false,
preserveHiddenOnSelectionChange: true,
},
syncGridSelectionWithBackendService: false, // but disable it when using backend services
},
datasetIdPropertyName: 'id',
defaultFilter: Filters.input,
defaultBackendServiceFilterTypingDebounce: 500,
defaultColumnSortFieldId: 'id',
defaultFilterPlaceholder: '🔎︎',
defaultFilterRangeOperator: OperatorType.rangeInclusive,
editable: false,
enableAutoResize: true,
enableAutoSizeColumns: true,
enableCellNavigation: false,
enableColumnPicker: true,
enableColumnReorder: true,
enableColumnResizeOnDoubleClick: true,
enableContextMenu: true,
enableExcelExport: false,
enableTextExport: false, // CSV/Text with Tab Delimited
enableFilterTrimWhiteSpace: false, // do we want to trim white spaces on all Filters?
enableGridMenu: true,
enableHeaderMenu: true,
enableEmptyDataWarningMessage: true,
emptyDataWarning: {
className: 'slick-empty-data-warning',
message: 'No data to display.',
messageKey: 'EMPTY_DATA_WARNING_MESSAGE',
hideFrozenLeftWarning: false,
hideFrozenRightWarning: false,
leftViewportMarginLeft: '40%',
rightViewportMarginLeft: '40%',
frozenLeftViewportMarginLeft: '0px',
frozenRightViewportMarginLeft: '40%',
},
enableMouseHoverHighlightRow: true,
enableSorting: true,
enableTextSelectionOnCells: true,
eventNamingStyle: EventNamingStyle.camelCase,
explicitInitialization: true,
excelExportOptions: {
addGroupIndentation: true,
exportWithFormatter: false,
filename: 'export',
format: FileType.xlsx,
groupingColumnHeaderTitle: 'Group By',
groupCollapsedSymbol: '⮞',
groupExpandedSymbol: '⮟',
groupingAggregatorRowText: '',
sanitizeDataExport: false,
},
textExportOptions: {
delimiter: DelimiterType.comma,
exportWithFormatter: false,
filename: 'export',
format: FileType.csv,
groupingColumnHeaderTitle: 'Group By',
groupingAggregatorRowText: '',
sanitizeDataExport: false,
useUtf8WithBom: true,
},
filterTypingDebounce: 0,
forceFitColumns: false,
frozenHeaderWidthCalcDifferential: 0,
gridMenu: {
dropSide: 'left',
commandLabels: {
clearAllFiltersCommandKey: 'CLEAR_ALL_FILTERS',
clearAllSortingCommandKey: 'CLEAR_ALL_SORTING',
clearFrozenColumnsCommandKey: 'CLEAR_PINNING',
exportCsvCommandKey: 'EXPORT_TO_CSV',
exportExcelCommandKey: 'EXPORT_TO_EXCEL',
exportTextDelimitedCommandKey: 'EXPORT_TO_TAB_DELIMITED',
refreshDatasetCommandKey: 'REFRESH_DATASET',
toggleDarkModeCommandKey: 'TOGGLE_DARK_MODE',
toggleFilterCommandKey: 'TOGGLE_FILTER_ROW',
togglePreHeaderCommandKey: 'TOGGLE_PRE_HEADER_ROW',
},
hideClearAllFiltersCommand: false,
hideClearAllSortingCommand: false,
hideClearFrozenColumnsCommand: true, // opt-in command
hideExportCsvCommand: false,
hideExportExcelCommand: false,
hideExportTextDelimitedCommand: true,
hideForceFitButton: false,
hideRefreshDatasetCommand: false,
hideSyncResizeButton: true,
hideToggleDarkModeCommand: true,
hideToggleFilterCommand: false,
hideTogglePreHeaderCommand: false,
iconCssClass: 'mdi mdi-menu',
iconClearAllFiltersCommand: 'mdi mdi-filter-remove-outline',
iconClearAllSortingCommand: 'mdi mdi-sort-variant-off',
iconClearFrozenColumnsCommand: 'mdi mdi-pin-off-outline',
iconExportCsvCommand: 'mdi mdi-download',
iconExportExcelCommand: 'mdi mdi-file-excel-outline',
iconExportTextDelimitedCommand: 'mdi mdi-download',
iconRefreshDatasetCommand: 'mdi mdi-sync',
iconToggleDarkModeCommand: 'mdi mdi-brightness-4',
iconToggleFilterCommand: 'mdi mdi-flip-vertical',
iconTogglePreHeaderCommand: 'mdi mdi-flip-vertical',
menuWidth: 16,
resizeOnShowHeaderRow: true,
subItemChevronClass: 'mdi mdi-chevron-down mdi-rotate-270',
headerColumnValueExtractor: pickerHeaderColumnValueExtractor,
},
headerMenu: {
autoAlign: true,
autoAlignOffset: 12,
minWidth: 140,
iconClearFilterCommand: 'mdi mdi-filter-remove-outline',
iconClearSortCommand: 'mdi mdi-sort-variant-off',
iconFreezeColumns: 'mdi mdi-pin-outline',
iconSortAscCommand: 'mdi mdi-sort-ascending',
iconSortDescCommand: 'mdi mdi-sort-descending',
iconColumnHideCommand: 'mdi mdi-close',
iconColumnResizeByContentCommand: 'mdi mdi-arrow-expand-horizontal',
hideColumnResizeByContentCommand: false,
hideColumnHideCommand: false,
hideClearFilterCommand: false,
hideClearSortCommand: false,
hideFreezeColumnsCommand: true, // opt-in command
hideSortCommands: false,
subItemChevronClass: 'mdi mdi-chevron-down mdi-rotate-270',
},
headerRowHeight: 35,
multiColumnSort: true,
numberedMultiColumnSort: true,
tristateMultiColumnSort: false,
sortColNumberInSeparateSpan: true,
suppressActiveCellChangeOnEdit: false,
pagination: {
pageSizes: [10, 15, 20, 25, 30, 40, 50, 75, 100],
pageSize: 25,
totalItems: 0,
},
// technically speaking the Row Detail requires the process & viewComponent but we'll ignore it just to set certain options
rowDetailView: {
collapseAllOnSort: true,
cssClass: 'detail-view-toggle',
panelRows: 1,
keyPrefix: '__',
useRowClick: false,
saveDetailViewOnScroll: false,
} as RowDetailView,
rowHeight: 35,
topPanelHeight: 35,
preHeaderPanelWidth: '100%', // mostly useful for Draggable Grouping dropzone to take full width
translationNamespaceSeparator: ':',
resetFilterSearchValueAfterOnBeforeCancellation: true,
resizeByContentOnlyOnFirstLoad: true,
resizeByContentOptions: {
alwaysRecalculateColumnWidth: false,
cellCharWidthInPx: 7.8,
cellPaddingWidthInPx: 14,
defaultRatioForStringType: 0.88,
formatterPaddingWidthInPx: 0,
maxItemToInspectCellContentWidth: 1000,
maxItemToInspectSingleColumnWidthByContent: 5000,
widthToRemoveFromExceededWidthReadjustment: 50,
},
treeDataOptions: {
exportIndentMarginLeft: 5,
exportIndentationLeadingChar: '͏͏͏͏͏͏͏͏͏·',
} as unknown as TreeDataOption,
};
/**
* Value Extractor for both ColumnPicker & GridMenu Picker
* when using Column Header Grouping, we'll prefix the column group title
* else we'll simply return the column name title
*/
function pickerHeaderColumnValueExtractor(column: Column, gridOptions?: GridOptionUniversal) {
let colName = column?.columnPickerLabel ?? column?.name ?? '';
if (colName instanceof HTMLElement || colName instanceof DocumentFragment) {
colName = colName.textContent || '';
}
const headerGroup = column?.columnGroup || '';
const columnGroupSeparator = gridOptions?.columnGroupSeparator ?? ' - ';
if (headerGroup) {
return headerGroup + columnGroupSeparator + colName;
}
return colName;
}