angular-slickgrid 4.2.0 → 4.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (232) hide show
  1. package/{dist/angular-slickgrid.d.ts → angular-slickgrid.d.ts} +0 -0
  2. package/{dist/app → app}/modules/angular-slickgrid/components/angular-slickgrid.component.d.ts +0 -0
  3. package/{dist/app → app}/modules/angular-slickgrid/constants.d.ts +0 -0
  4. package/{dist/app → app}/modules/angular-slickgrid/extensions/index.d.ts +0 -0
  5. package/{dist/app → app}/modules/angular-slickgrid/extensions/slickRowDetailView.d.ts +0 -0
  6. package/{dist/app → app}/modules/angular-slickgrid/global-grid-options.d.ts +0 -0
  7. package/{dist/app → app}/modules/angular-slickgrid/index.d.ts +0 -0
  8. package/{dist/app → app}/modules/angular-slickgrid/models/angularComponentOutput.interface.d.ts +0 -0
  9. package/{dist/app → app}/modules/angular-slickgrid/models/angularGridInstance.interface.d.ts +0 -0
  10. package/{dist/app → app}/modules/angular-slickgrid/models/externalTestingDependencies.interface.d.ts +0 -0
  11. package/{dist/app → app}/modules/angular-slickgrid/models/gridOption.interface.d.ts +0 -0
  12. package/{dist/app → app}/modules/angular-slickgrid/models/index.d.ts +0 -0
  13. package/{dist/app → app}/modules/angular-slickgrid/models/rowDetailView.interface.d.ts +0 -0
  14. package/{dist/app → app}/modules/angular-slickgrid/models/slickGrid.interface.d.ts +0 -0
  15. package/{dist/app → app}/modules/angular-slickgrid/modules/angular-slickgrid.module.d.ts +0 -0
  16. package/{dist/app → app}/modules/angular-slickgrid/services/angularUtil.service.d.ts +0 -0
  17. package/{dist/app → app}/modules/angular-slickgrid/services/bsDropdown.service.d.ts +0 -0
  18. package/{dist/app → app}/modules/angular-slickgrid/services/container.service.d.ts +0 -0
  19. package/{dist/app → app}/modules/angular-slickgrid/services/index.d.ts +0 -0
  20. package/{dist/app → app}/modules/angular-slickgrid/services/translater.service.d.ts +0 -0
  21. package/{dist/app → app}/modules/angular-slickgrid/services/utilities.d.ts +0 -0
  22. package/{dist/app → app}/modules/angular-slickgrid/slickgrid-config.d.ts +0 -0
  23. package/docs/assets/lib/multiple-select/README.md +17 -0
  24. package/{dist/esm2020 → esm2020}/angular-slickgrid.mjs +0 -0
  25. package/{dist/esm2020 → esm2020}/app/modules/angular-slickgrid/components/angular-slickgrid.component.mjs +0 -0
  26. package/{dist/esm2020 → esm2020}/app/modules/angular-slickgrid/constants.mjs +0 -0
  27. package/{dist/esm2020 → esm2020}/app/modules/angular-slickgrid/extensions/index.mjs +0 -0
  28. package/{dist/esm2020 → esm2020}/app/modules/angular-slickgrid/extensions/slickRowDetailView.mjs +0 -0
  29. package/{dist/esm2020 → esm2020}/app/modules/angular-slickgrid/global-grid-options.mjs +0 -0
  30. package/{dist/esm2020 → esm2020}/app/modules/angular-slickgrid/index.mjs +0 -0
  31. package/{dist/esm2020 → esm2020}/app/modules/angular-slickgrid/models/angularComponentOutput.interface.mjs +0 -0
  32. package/{dist/esm2020 → esm2020}/app/modules/angular-slickgrid/models/angularGridInstance.interface.mjs +0 -0
  33. package/{dist/esm2020 → esm2020}/app/modules/angular-slickgrid/models/externalTestingDependencies.interface.mjs +0 -0
  34. package/{dist/esm2020 → esm2020}/app/modules/angular-slickgrid/models/gridOption.interface.mjs +0 -0
  35. package/{dist/esm2020 → esm2020}/app/modules/angular-slickgrid/models/index.mjs +0 -0
  36. package/{dist/esm2020 → esm2020}/app/modules/angular-slickgrid/models/rowDetailView.interface.mjs +0 -0
  37. package/{dist/esm2020 → esm2020}/app/modules/angular-slickgrid/models/slickGrid.interface.mjs +0 -0
  38. package/{dist/esm2020 → esm2020}/app/modules/angular-slickgrid/modules/angular-slickgrid.module.mjs +0 -0
  39. package/{dist/esm2020 → esm2020}/app/modules/angular-slickgrid/services/angularUtil.service.mjs +0 -0
  40. package/{dist/esm2020 → esm2020}/app/modules/angular-slickgrid/services/bsDropdown.service.mjs +0 -0
  41. package/{dist/esm2020 → esm2020}/app/modules/angular-slickgrid/services/container.service.mjs +0 -0
  42. package/{dist/esm2020 → esm2020}/app/modules/angular-slickgrid/services/index.mjs +0 -0
  43. package/{dist/esm2020 → esm2020}/app/modules/angular-slickgrid/services/translater.service.mjs +0 -0
  44. package/{dist/esm2020 → esm2020}/app/modules/angular-slickgrid/services/utilities.mjs +0 -0
  45. package/{dist/esm2020 → esm2020}/app/modules/angular-slickgrid/slickgrid-config.mjs +0 -0
  46. package/{dist/esm2020 → esm2020}/public_api.mjs +0 -0
  47. package/{dist/fesm2015 → fesm2015}/angular-slickgrid.mjs +0 -0
  48. package/{dist/fesm2015 → fesm2015}/angular-slickgrid.mjs.map +0 -0
  49. package/{dist/fesm2020 → fesm2020}/angular-slickgrid.mjs +0 -0
  50. package/{dist/fesm2020 → fesm2020}/angular-slickgrid.mjs.map +0 -0
  51. package/{dist/i18n → i18n}/en.json +0 -0
  52. package/{dist/i18n → i18n}/fr.json +0 -0
  53. package/package.json +25 -110
  54. package/{dist/public_api.d.ts → public_api.d.ts} +0 -0
  55. package/.browserslistrc +0 -12
  56. package/.codecov.yml +0 -17
  57. package/.editorconfig +0 -18
  58. package/.eslintrc.json +0 -50
  59. package/.github/CODE_OF_CONDUCT.md +0 -76
  60. package/.github/FUNDING.yml +0 -8
  61. package/.github/ISSUE_TEMPLATE/bug_report.yml +0 -54
  62. package/.github/ISSUE_TEMPLATE/config.yml +0 -5
  63. package/.github/ISSUE_TEMPLATE/feature_request.yml +0 -44
  64. package/.github/renovate.json5 +0 -26
  65. package/.github/stale.yml +0 -7
  66. package/.github/workflows/main.yml +0 -83
  67. package/.vscode/extensions.json +0 -9
  68. package/.vscode/launch.json +0 -72
  69. package/.vscode/settings.json +0 -7
  70. package/.vscode/tasks.json +0 -77
  71. package/CHANGELOG.md +0 -1172
  72. package/angular.json +0 -148
  73. package/dist/LICENSE +0 -20
  74. package/dist/README.md +0 -182
  75. package/dist/package.json +0 -79
  76. package/global.d.ts +0 -1
  77. package/ngcc.config.js +0 -13
  78. package/screenshots/column-picker.png +0 -0
  79. package/screenshots/composite-editor.png +0 -0
  80. package/screenshots/draggable-grouping.png +0 -0
  81. package/screenshots/editors.png +0 -0
  82. package/screenshots/export-to-file.png +0 -0
  83. package/screenshots/filter_and_sort.png +0 -0
  84. package/screenshots/formatters.png +0 -0
  85. package/screenshots/frozen.png +0 -0
  86. package/screenshots/multipleSelectFilter.png +0 -0
  87. package/screenshots/pagination.png +0 -0
  88. package/screenshots/selectFilter.png +0 -0
  89. package/screenshots/singleFilter.png +0 -0
  90. package/src/app/app-routing.module.ts +0 -83
  91. package/src/app/app.component.html +0 -160
  92. package/src/app/app.component.scss +0 -65
  93. package/src/app/app.component.ts +0 -10
  94. package/src/app/app.module.ts +0 -175
  95. package/src/app/examples/custom-angularComponentEditor.ts +0 -184
  96. package/src/app/examples/custom-angularComponentFilter.ts +0 -126
  97. package/src/app/examples/custom-inputEditor.ts +0 -124
  98. package/src/app/examples/custom-inputFilter.ts +0 -142
  99. package/src/app/examples/custom-titleFormatter.component.ts +0 -8
  100. package/src/app/examples/editor-ng-select.component.ts +0 -37
  101. package/src/app/examples/filter-ng-select.component.ts +0 -32
  102. package/src/app/examples/grid-additem.component.html +0 -48
  103. package/src/app/examples/grid-additem.component.ts +0 -272
  104. package/src/app/examples/grid-angular.component.html +0 -79
  105. package/src/app/examples/grid-angular.component.scss +0 -28
  106. package/src/app/examples/grid-angular.component.ts +0 -370
  107. package/src/app/examples/grid-autoheight.component.html +0 -52
  108. package/src/app/examples/grid-autoheight.component.ts +0 -147
  109. package/src/app/examples/grid-basic.component.html +0 -29
  110. package/src/app/examples/grid-basic.component.ts +0 -82
  111. package/src/app/examples/grid-clientside.component.html +0 -51
  112. package/src/app/examples/grid-clientside.component.ts +0 -293
  113. package/src/app/examples/grid-colspan.component.html +0 -39
  114. package/src/app/examples/grid-colspan.component.scss +0 -11
  115. package/src/app/examples/grid-colspan.component.ts +0 -155
  116. package/src/app/examples/grid-composite-editor.component.html +0 -79
  117. package/src/app/examples/grid-composite-editor.component.scss +0 -19
  118. package/src/app/examples/grid-composite-editor.component.ts +0 -948
  119. package/src/app/examples/grid-contextmenu.component.html +0 -62
  120. package/src/app/examples/grid-contextmenu.component.scss +0 -44
  121. package/src/app/examples/grid-contextmenu.component.ts +0 -473
  122. package/src/app/examples/grid-custom-tooltip.component.html +0 -25
  123. package/src/app/examples/grid-custom-tooltip.component.scss +0 -77
  124. package/src/app/examples/grid-custom-tooltip.component.ts +0 -483
  125. package/src/app/examples/grid-draggrouping.component.html +0 -93
  126. package/src/app/examples/grid-draggrouping.component.ts +0 -397
  127. package/src/app/examples/grid-editor.component.html +0 -88
  128. package/src/app/examples/grid-editor.component.ts +0 -699
  129. package/src/app/examples/grid-formatter.component.html +0 -26
  130. package/src/app/examples/grid-formatter.component.ts +0 -162
  131. package/src/app/examples/grid-frozen.component.html +0 -65
  132. package/src/app/examples/grid-frozen.component.scss +0 -11
  133. package/src/app/examples/grid-frozen.component.ts +0 -303
  134. package/src/app/examples/grid-graphql-nopage.component.html +0 -33
  135. package/src/app/examples/grid-graphql-nopage.component.scss +0 -9
  136. package/src/app/examples/grid-graphql-nopage.component.ts +0 -242
  137. package/src/app/examples/grid-graphql.component.html +0 -87
  138. package/src/app/examples/grid-graphql.component.ts +0 -304
  139. package/src/app/examples/grid-grouping.component.html +0 -80
  140. package/src/app/examples/grid-grouping.component.ts +0 -313
  141. package/src/app/examples/grid-headerbutton.component.html +0 -31
  142. package/src/app/examples/grid-headerbutton.component.scss +0 -10
  143. package/src/app/examples/grid-headerbutton.component.ts +0 -233
  144. package/src/app/examples/grid-headermenu.component.html +0 -31
  145. package/src/app/examples/grid-headermenu.component.scss +0 -25
  146. package/src/app/examples/grid-headermenu.component.ts +0 -159
  147. package/src/app/examples/grid-localization.component.html +0 -54
  148. package/src/app/examples/grid-localization.component.ts +0 -293
  149. package/src/app/examples/grid-menu.component.html +0 -37
  150. package/src/app/examples/grid-menu.component.scss +0 -28
  151. package/src/app/examples/grid-menu.component.ts +0 -229
  152. package/src/app/examples/grid-odata.component.html +0 -116
  153. package/src/app/examples/grid-odata.component.ts +0 -441
  154. package/src/app/examples/grid-range.component.html +0 -74
  155. package/src/app/examples/grid-range.component.ts +0 -291
  156. package/src/app/examples/grid-remote.component.html +0 -37
  157. package/src/app/examples/grid-remote.component.ts +0 -153
  158. package/src/app/examples/grid-resize-by-content.component.html +0 -62
  159. package/src/app/examples/grid-resize-by-content.component.scss +0 -19
  160. package/src/app/examples/grid-resize-by-content.component.ts +0 -780
  161. package/src/app/examples/grid-rowdetail.component.html +0 -35
  162. package/src/app/examples/grid-rowdetail.component.ts +0 -205
  163. package/src/app/examples/grid-rowmove.component.html +0 -49
  164. package/src/app/examples/grid-rowmove.component.ts +0 -234
  165. package/src/app/examples/grid-rowselection.component.html +0 -76
  166. package/src/app/examples/grid-rowselection.component.ts +0 -267
  167. package/src/app/examples/grid-state.component.html +0 -36
  168. package/src/app/examples/grid-state.component.ts +0 -259
  169. package/src/app/examples/grid-tabs.component.html +0 -35
  170. package/src/app/examples/grid-tabs.component.ts +0 -115
  171. package/src/app/examples/grid-trading.component.html +0 -58
  172. package/src/app/examples/grid-trading.component.scss +0 -49
  173. package/src/app/examples/grid-trading.component.ts +0 -319
  174. package/src/app/examples/grid-tree-data-hierarchical.component.html +0 -79
  175. package/src/app/examples/grid-tree-data-hierarchical.component.scss +0 -47
  176. package/src/app/examples/grid-tree-data-hierarchical.component.ts +0 -311
  177. package/src/app/examples/grid-tree-data-parent-child.component.html +0 -108
  178. package/src/app/examples/grid-tree-data-parent-child.component.scss +0 -10
  179. package/src/app/examples/grid-tree-data-parent-child.component.ts +0 -351
  180. package/src/app/examples/home.component.html +0 -41
  181. package/src/app/examples/home.component.ts +0 -9
  182. package/src/app/examples/rowdetail-preload.component.ts +0 -10
  183. package/src/app/examples/rowdetail-view.component.html +0 -36
  184. package/src/app/examples/rowdetail-view.component.ts +0 -54
  185. package/src/app/examples/swt-common-grid-pagination.component.ts +0 -156
  186. package/src/app/examples/swt-common-grid-test.component.html +0 -30
  187. package/src/app/examples/swt-common-grid-test.component.ts +0 -219
  188. package/src/app/examples/swt-common-grid.component.ts +0 -436
  189. package/src/app/examples/swt-logger.service.ts +0 -165
  190. package/src/app/modules/angular-slickgrid/components/angular-slickgrid.component.html +0 -4
  191. package/src/app/modules/angular-slickgrid/components/angular-slickgrid.component.ts +0 -1395
  192. package/src/app/modules/angular-slickgrid/constants.ts +0 -97
  193. package/src/app/modules/angular-slickgrid/extensions/index.ts +0 -1
  194. package/src/app/modules/angular-slickgrid/extensions/slickRowDetailView.ts +0 -375
  195. package/src/app/modules/angular-slickgrid/global-grid-options.ts +0 -245
  196. package/src/app/modules/angular-slickgrid/index.ts +0 -11
  197. package/src/app/modules/angular-slickgrid/models/angularComponentOutput.interface.ts +0 -6
  198. package/src/app/modules/angular-slickgrid/models/angularGridInstance.interface.ts +0 -68
  199. package/src/app/modules/angular-slickgrid/models/externalTestingDependencies.interface.ts +0 -37
  200. package/src/app/modules/angular-slickgrid/models/gridOption.interface.ts +0 -12
  201. package/src/app/modules/angular-slickgrid/models/index.ts +0 -6
  202. package/src/app/modules/angular-slickgrid/models/rowDetailView.interface.ts +0 -33
  203. package/src/app/modules/angular-slickgrid/models/slickGrid.interface.ts +0 -7
  204. package/src/app/modules/angular-slickgrid/modules/angular-slickgrid.module.ts +0 -37
  205. package/src/app/modules/angular-slickgrid/services/angularUtil.service.ts +0 -48
  206. package/src/app/modules/angular-slickgrid/services/bsDropdown.service.ts +0 -142
  207. package/src/app/modules/angular-slickgrid/services/container.service.ts +0 -24
  208. package/src/app/modules/angular-slickgrid/services/index.ts +0 -5
  209. package/src/app/modules/angular-slickgrid/services/translater.service.ts +0 -38
  210. package/src/app/modules/angular-slickgrid/services/utilities.ts +0 -19
  211. package/src/app/modules/angular-slickgrid/slickgrid-config.ts +0 -10
  212. package/src/app/slickgrid-custom-variables.scss +0 -10
  213. package/src/assets/.gitkeep +0 -0
  214. package/src/assets/data/collection_100_numbers.json +0 -12
  215. package/src/assets/data/collection_500_numbers.json +0 -52
  216. package/src/assets/data/countries.json +0 -245
  217. package/src/assets/data/country_names.json +0 -245
  218. package/src/assets/data/customers_100.json +0 -102
  219. package/src/assets/i18n/en.json +0 -90
  220. package/src/assets/i18n/fr.json +0 -91
  221. package/src/environments/environment.prod.ts +0 -3
  222. package/src/environments/environment.ts +0 -8
  223. package/src/favicon.ico +0 -0
  224. package/src/index.html +0 -18
  225. package/src/main.ts +0 -13
  226. package/src/polyfills.ts +0 -52
  227. package/src/public_api.ts +0 -1
  228. package/src/styles.scss +0 -66
  229. package/src/typings.d.ts +0 -10
  230. package/tsconfig.app.json +0 -25
  231. package/tsconfig.json +0 -40
  232. package/tsconfig.spec.json +0 -23
@@ -1,699 +0,0 @@
1
- import { Component, OnInit } from '@angular/core';
2
- import { HttpClient } from '@angular/common/http';
3
- import { TranslateService } from '@ngx-translate/core';
4
- import { Instance as FlatpickrInstance } from 'flatpickr/dist/types/instance';
5
- import {
6
- AngularGridInstance,
7
- AutocompleteOption,
8
- Column,
9
- Editors,
10
- EditorArguments,
11
- EditorValidator,
12
- FieldType,
13
- Filters,
14
- FlatpickrOption,
15
- Formatter,
16
- Formatters,
17
- GridOption,
18
- LongTextEditorOption,
19
- OnEventArgs,
20
- OperatorType,
21
- SortComparers,
22
- SlickNamespace,
23
- } from './../modules/angular-slickgrid';
24
- import { CustomInputEditor } from './custom-inputEditor';
25
- import { CustomInputFilter } from './custom-inputFilter';
26
- import { Subject } from 'rxjs';
27
-
28
- // using external non-typed js libraries
29
- declare const Slick: SlickNamespace;
30
-
31
- const NB_ITEMS = 100;
32
- const URL_SAMPLE_COLLECTION_DATA = 'assets/data/collection_100_numbers.json';
33
- const URL_COUNTRIES_COLLECTION = 'assets/data/countries.json';
34
- const URL_COUNTRY_NAMES = 'assets/data/country_names.json';
35
-
36
- // you can create custom validator to pass to an inline editor
37
- const myCustomTitleValidator: EditorValidator = (value: any, args?: EditorArguments) => {
38
- // you can get the Editor Args which can be helpful, e.g. we can get the Translate Service from it
39
- const grid = args && args.grid;
40
- const gridOptions = (grid?.getOptions?.() ?? {}) as GridOption;
41
- const translate = gridOptions.i18n;
42
-
43
- // to get the editor object, you'll need to use "internalColumnEditor"
44
- // don't use "editor" property since that one is what SlickGrid uses internally by it's editor factory
45
- const columnEditor = args && args.column && args.column.internalColumnEditor;
46
-
47
- if (value === null || value === undefined || !value.length) {
48
- return { valid: false, msg: 'This is a required field' };
49
- } else if (!/^Task\s\d+$/.test(value)) {
50
- return { valid: false, msg: 'Your title is invalid, it must start with "Task" followed by a number' };
51
- // OR use the Translate Service with your custom message
52
- // return { valid: false, msg: translate.instant('YOUR_ERROR', { x: value }) };
53
- }
54
- return { valid: true, msg: '' };
55
- };
56
-
57
- // create a custom Formatter to show the Task + value
58
- const taskFormatter: Formatter = (row, cell, value, columnDef, dataContext) => {
59
- if (value && Array.isArray(value)) {
60
- const taskValues = value.map((val) => `Task ${val}`);
61
- const values = taskValues.join(', ');
62
- return `<span title="${values}">${values}</span>`;
63
- }
64
- return '';
65
- };
66
- @Component({
67
- templateUrl: './grid-editor.component.html'
68
- })
69
- export class GridEditorComponent implements OnInit {
70
- title = 'Example 3: Editors / Delete';
71
- subTitle = `
72
- Grid with Inline Editors and onCellClick actions (<a href="https://github.com/ghiscoding/Angular-Slickgrid/wiki/Editors" target="_blank">Wiki docs</a>).
73
- <ul>
74
- <li>Multiple Editors & Filters are available: AutoComplete, Checkbox, Date, Slider, SingleSelect, MultipleSelect, Float, Text, LongText... even Custom Editor</li>
75
- <li>When using "enableCellNavigation: true", clicking on a cell will automatically make it active &amp; selected.</li>
76
- <ul><li>If you don't want this behavior, then you should disable "enableCellNavigation"</li></ul>
77
- <li>Inline Editors requires "enableCellNavigation: true" (not sure why though)</li>
78
- <li>
79
- Support Excel Copy Buffer (SlickGrid Copy Manager Plugin), you can use it by simply enabling "enableExcelCopyBuffer" flag.
80
- Note that it will only evaluate Formatter when the "exportWithFormatter" flag is enabled (through "ExportOptions" or the column definition)
81
- </li>
82
- <li>MultipleSelect & SingeSelect Editors & Filters can use a regular "collection" or "collectionAsync" to load it asynchronously</li>
83
- <ul>
84
- <li>Click on "Add Item" and see the Editor/Filter or the "Prerequesites" column change</li>
85
- <li>Any Editor/Filter with a "collection" can be changed dynamically later in the future</li>
86
- </ul>
87
- </ul>
88
- `;
89
-
90
- private _commandQueue: any = [];
91
- angularGrid!: AngularGridInstance;
92
- columnDefinitions!: Column[];
93
- gridOptions!: GridOption;
94
- dataset!: any[];
95
- gridObj: any;
96
- isAutoEdit = true;
97
- alertWarning: any;
98
- updatedObject: any;
99
- selectedLanguage = 'en';
100
- duplicateTitleHeaderCount = 1;
101
-
102
- constructor(private http: HttpClient, private translate: TranslateService) { }
103
-
104
- ngOnInit() {
105
- this.prepareGrid();
106
- }
107
-
108
- angularGridReady(angularGrid: AngularGridInstance) {
109
- this.angularGrid = angularGrid;
110
- this.gridObj = angularGrid.slickGrid;
111
- }
112
-
113
- prepareGrid() {
114
- this.columnDefinitions = [
115
- {
116
- id: 'edit',
117
- field: 'id',
118
- excludeFromColumnPicker: true,
119
- excludeFromGridMenu: true,
120
- excludeFromHeaderMenu: true,
121
- formatter: Formatters.editIcon,
122
- minWidth: 30,
123
- maxWidth: 30,
124
- // use onCellClick OR grid.onClick.subscribe which you can see down below
125
- onCellClick: (e: Event, args: OnEventArgs) => {
126
- console.log(args);
127
- this.alertWarning = `Editing: ${args.dataContext.title}`;
128
- this.angularGrid.gridService.highlightRow(args.row, 1500);
129
- this.angularGrid.gridService.setSelectedRow(args.row);
130
- }
131
- }, {
132
- id: 'delete',
133
- field: 'id',
134
- excludeFromColumnPicker: true,
135
- excludeFromGridMenu: true,
136
- excludeFromHeaderMenu: true,
137
- formatter: Formatters.deleteIcon,
138
- minWidth: 30,
139
- maxWidth: 30,
140
- // use onCellClick OR grid.onClick.subscribe which you can see down below
141
- /*
142
- onCellClick: (e: Event, args: OnEventArgs) => {
143
- console.log(args);
144
- this.alertWarning = `Deleting: ${args.dataContext.title}`;
145
- }
146
- */
147
- }, {
148
- id: 'title',
149
- name: 'Title',
150
- field: 'title',
151
- minWidth: 100,
152
- filterable: true,
153
- sortable: true,
154
- type: FieldType.string,
155
- editor: {
156
- model: Editors.longText,
157
- required: true,
158
- maxLength: 12,
159
- editorOptions: {
160
- // you can change textarea cols,rows (defaults to 40,4)
161
- cols: 42,
162
- rows: 5,
163
- buttonTexts: {
164
- /* you can change button texts (defaults to "Cancel", "Save") */
165
- // cancel: 'Close',
166
- // save: 'Done'
167
-
168
- /* or with translations (defaults to "CANCEL", "SAVE") */
169
- // cancelKey: 'CANCEL',
170
- // saveKey: 'SAVE'
171
- }
172
- } as LongTextEditorOption,
173
- validator: myCustomTitleValidator,
174
- },
175
- onCellChange: (e: Event, args: OnEventArgs) => {
176
- console.log(args);
177
- this.alertWarning = `Updated Title: ${args.dataContext.title}`;
178
- }
179
- }, {
180
- id: 'title2',
181
- name: 'Title, Custom Editor',
182
- field: 'title',
183
- minWidth: 70,
184
- filterable: true,
185
- sortable: true,
186
- type: FieldType.string,
187
- editor: {
188
- model: CustomInputEditor,
189
- placeholder: 'custom',
190
- validator: myCustomTitleValidator, // use a custom validator
191
- },
192
- filter: {
193
- model: CustomInputFilter,
194
- placeholder: '🔎︎ custom',
195
- },
196
- }, {
197
- id: 'duration',
198
- name: 'Duration (days)',
199
- field: 'duration',
200
- minWidth: 100,
201
- filterable: true,
202
- sortable: true,
203
- formatter: Formatters.complexObject,
204
- type: FieldType.number,
205
- exportWithFormatter: true,
206
- filter: { model: Filters.slider, params: { hideSliderNumber: false } },
207
- editor: {
208
- model: Editors.slider,
209
- minValue: 0,
210
- maxValue: 100,
211
- // params: { hideSliderNumber: true },
212
- },
213
- /*
214
- editor: {
215
- // default is 0 decimals, if no decimals is passed it will accept 0 or more decimals
216
- // however if you pass the "decimalPlaces", it will validate with that maximum
217
- alwaysSaveOnEnterKey: true, // defaults to False, when set to true and user presses ENTER it will always call a Save even if value is empty
218
- model: Editors.float,
219
- placeholder: 'enter number',
220
- title: 'Your number must be bigger than 5', // add a custom title, to see it as a real tooltip you'll need to implement something like tipsy jquery lib
221
- minValue: 5,
222
- maxValue: 365,
223
- // the default validation error message is in English but you can override it by using "errorMessage"
224
- // errorMessage: this.i18n.tr('INVALID_FLOAT', { maxDecimal: 2 }),
225
- params: { decimalPlaces: 2 },
226
- },
227
- */
228
- }, {
229
- id: 'complete',
230
- name: '% Complete',
231
- field: 'percentComplete',
232
- minWidth: 100,
233
- filterable: true,
234
- formatter: Formatters.multiple,
235
- type: FieldType.number,
236
- editor: {
237
- model: Editors.singleSelect,
238
-
239
- // We can also add HTML text to be rendered (any bad script will be sanitized) but we have to opt-in, else it will be sanitized
240
- enableRenderHtml: true,
241
- collection: Array.from(Array(101).keys()).map(k => ({ value: k, label: k, symbol: '<i class="fa fa-percent" style="color:cadetblue"></i>' })),
242
- customStructure: {
243
- value: 'value',
244
- label: 'label',
245
- labelSuffix: 'symbol'
246
- },
247
-
248
- // collection: Array.from(Array(101).keys()).map(k => ({ value: k, label: k, labelSuffix: '%' })),
249
- collectionSortBy: {
250
- property: 'label',
251
- sortDesc: true
252
- },
253
- collectionFilterBy: {
254
- property: 'value',
255
- value: 0,
256
- operator: OperatorType.notEqual
257
- },
258
- // you could also provide a collection override to filter/sort based on the item dataContext or whatever else
259
- // collectionOverride: (updatedCollection, args) => {
260
- // console.log(args);
261
- // return updatedCollection.filter((col) => args.dataContext.id % 2 ? col.value < 50 : col.value >= 50);
262
- // },
263
- editorOptions: {
264
- maxHeight: 400
265
- }
266
- },
267
- params: {
268
- formatters: [Formatters.collectionEditor, Formatters.percentCompleteBar],
269
- },
270
- // validator: (value, args) => {
271
- // if (value < 50) {
272
- // return { valid: false, msg: 'Please use at least 50%' };
273
- // }
274
- // return { valid: true, msg: '' };
275
- // }
276
- }, {
277
- id: 'start',
278
- name: 'Start',
279
- field: 'start',
280
- minWidth: 100,
281
- filterable: true,
282
- filter: { model: Filters.compoundDate },
283
- formatter: Formatters.multiple,
284
- params: {
285
- formatters: [Formatters.complexObject, Formatters.dateIso]
286
- },
287
- exportWithFormatter: true,
288
- sortable: true,
289
- type: FieldType.date,
290
- editor: {
291
- model: Editors.date,
292
- },
293
- }, {
294
- id: 'finish',
295
- name: 'Finish',
296
- field: 'finish',
297
- minWidth: 100,
298
- filterable: true,
299
- sortable: true,
300
- filter: { model: Filters.compoundDate },
301
- formatter: Formatters.dateIso,
302
- exportWithFormatter: true,
303
- type: FieldType.date, // dataset cell input format
304
- // outputType: FieldType.dateUs, // date picker format
305
- saveOutputType: FieldType.dateUtc, // save output date formattype: FieldType.date,
306
- editor: {
307
- model: Editors.date,
308
- // override any of the Flatpickr options through "editorOptions"
309
- // please note that there's no TSlint on this property since it's generic for any filter, so make sure you entered the correct filter option(s)
310
- editorOptions: {
311
- minDate: 'today',
312
-
313
- // if we want to preload the date picker with a different date,
314
- // we could toggle the `closeOnSelect: false`, set the date in the picker and re-toggle `closeOnSelect: true`
315
- // closeOnSelect: false,
316
- // onOpen: (selectedDates: Date[] | Date, dateStr: string, instance: FlatpickrInstance) => {
317
- // instance.setDate('2021-12-31', true);
318
- // instance.set('closeOnSelect', true);
319
- // },
320
- } as FlatpickrOption
321
- },
322
- }, {
323
- id: 'cityOfOrigin', name: 'City of Origin', field: 'cityOfOrigin',
324
- filterable: true,
325
- minWidth: 100,
326
- editor: {
327
- model: Editors.autoComplete,
328
- placeholder: '🔎︎ search city',
329
-
330
- // We can use the autocomplete through 3 ways "collection", "collectionAsync" or with your own autocomplete options
331
- // use your own autocomplete options, instead of $.ajax, use http
332
- // here we use $.ajax just because I'm not sure how to configure http with JSONP and CORS
333
- editorOptions: {
334
- forceUserInput: true,
335
- minLength: 3,
336
- source: (request, response) => {
337
- /** with Angular Http, note this demo won't work because of CORS */
338
- // this.http.get(`http://gd.geobytes.com/AutoCompleteCity?q=${request.term}`).subscribe(data => response(data));
339
-
340
- /** with jQuery AJAX will work locally but not on the GitHub demo because of CORS */
341
- $.ajax({
342
- url: 'http://gd.geobytes.com/AutoCompleteCity',
343
- dataType: 'jsonp',
344
- data: {
345
- q: request.term
346
- },
347
- success: (data: any) => response(data)
348
- });
349
- }
350
- } as AutocompleteOption,
351
- },
352
- filter: {
353
- model: Filters.autoComplete,
354
- // placeholder: '🔎︎ search city',
355
-
356
- // We can use the autocomplete through 3 ways "collection", "collectionAsync" or with your own autocomplete options
357
- // collectionAsync: this.http.get(URL_COUNTRIES_COLLECTION),
358
-
359
- // OR use your own autocomplete options, instead of $.ajax, use http
360
- // here we use $.ajax just because I'm not sure how to configure http with JSONP and CORS
361
- filterOptions: {
362
- minLength: 3,
363
- source: (request, response) => {
364
- $.ajax({
365
- url: 'http://gd.geobytes.com/AutoCompleteCity',
366
- dataType: 'jsonp',
367
- data: {
368
- q: request.term
369
- },
370
- success: (data: any) => response(data)
371
- });
372
- }
373
- } as AutocompleteOption,
374
- }
375
- }, {
376
- id: 'countryOfOrigin', name: 'Country of Origin', field: 'countryOfOrigin',
377
- formatter: Formatters.complexObject,
378
- exportWithFormatter: true,
379
- dataKey: 'code',
380
- labelKey: 'name',
381
- type: FieldType.object,
382
- sortComparer: SortComparers.objectString, // this sorter requires the dataKey and assume that obj1[dataKey] will be a string so it can sort it that way
383
- filterable: true,
384
- sortable: true,
385
- minWidth: 100,
386
- editor: {
387
- model: Editors.autoComplete,
388
- customStructure: { label: 'name', value: 'code' },
389
- collectionAsync: this.http.get(URL_COUNTRIES_COLLECTION),
390
- },
391
- filter: {
392
- model: Filters.autoComplete,
393
- customStructure: { label: 'name', value: 'code' },
394
- collectionAsync: this.http.get(URL_COUNTRIES_COLLECTION),
395
- }
396
- }, {
397
- id: 'countryOfOriginName', name: 'Country of Origin Name', field: 'countryOfOriginName',
398
- filterable: true,
399
- sortable: true,
400
- minWidth: 100,
401
- editor: {
402
- model: Editors.autoComplete,
403
- collectionAsync: this.http.get(URL_COUNTRY_NAMES),
404
- },
405
- filter: {
406
- model: Filters.autoComplete,
407
- collectionAsync: this.http.get(URL_COUNTRY_NAMES),
408
- }
409
- }, {
410
- id: 'effort-driven',
411
- name: 'Effort Driven',
412
- field: 'effortDriven',
413
- minWidth: 70,
414
- filterable: true,
415
- type: FieldType.boolean,
416
- filter: {
417
- model: Filters.singleSelect,
418
- collection: [{ value: '', label: '' }, { value: true, label: 'True' }, { value: false, label: 'False' }],
419
- },
420
- formatter: Formatters.checkmark,
421
- editor: {
422
- model: Editors.checkbox,
423
- },
424
- }, {
425
- id: 'prerequisites',
426
- name: 'Prerequisites',
427
- field: 'prerequisites',
428
- minWidth: 100,
429
- filterable: true,
430
- formatter: taskFormatter,
431
- exportWithFormatter: true,
432
- sanitizeDataExport: true,
433
- sortable: true,
434
- type: FieldType.string,
435
- editor: {
436
- placeholder: 'choose option',
437
- collectionAsync: this.http.get<{ value: string; label: string; }[]>(URL_SAMPLE_COLLECTION_DATA),
438
- // OR a regular collection load
439
- // collection: Array.from(Array(100).keys()).map(k => ({ value: k, prefix: 'Task', label: k })),
440
- collectionSortBy: {
441
- property: 'label',
442
- sortDesc: true
443
- },
444
- customStructure: {
445
- label: 'label',
446
- value: 'value',
447
- labelPrefix: 'prefix',
448
- },
449
- collectionOptions: {
450
- separatorBetweenTextLabels: ' '
451
- },
452
- model: Editors.multipleSelect,
453
- required: true
454
- },
455
- filter: {
456
- collectionAsync: this.http.get<{ value: string; label: string; }[]>(URL_SAMPLE_COLLECTION_DATA),
457
- // OR a regular collection load
458
- // collection: Array.from(Array(100).keys()).map(k => ({ value: k, prefix: 'Task', label: k })),
459
- collectionSortBy: {
460
- property: 'label',
461
- sortDesc: true
462
- },
463
- customStructure: {
464
- label: 'label',
465
- value: 'value',
466
- labelPrefix: 'prefix',
467
- },
468
- collectionOptions: {
469
- separatorBetweenTextLabels: ' '
470
- },
471
- model: Filters.multipleSelect,
472
- operator: OperatorType.inContains,
473
- }
474
- }
475
- ];
476
-
477
- this.gridOptions = {
478
- asyncEditorLoading: false,
479
- autoEdit: this.isAutoEdit,
480
- autoCommitEdit: false,
481
- autoResize: {
482
- container: '#demo-container',
483
- rightPadding: 10
484
- },
485
- editable: true,
486
- enableCellNavigation: true,
487
- enableColumnPicker: true,
488
- enableExcelCopyBuffer: true,
489
- enableFiltering: true,
490
- editCommandHandler: (item, column, editCommand) => {
491
- this._commandQueue.push(editCommand);
492
- editCommand.execute();
493
- },
494
- i18n: this.translate
495
- };
496
-
497
- this.dataset = this.mockData(NB_ITEMS);
498
- }
499
-
500
- /** Add a new row to the grid and refresh the Filter collection.
501
- * Note that because Filter elements are always displayed on the screen, we need to tell the Filter,
502
- * we do this via a Subject .next(), that it's collection got changed
503
- * as for the Editor, there's nothing to do since the element is not shown and it will have latest collection next time it shows up
504
- */
505
- addItem() {
506
- const lastRowIndex = this.dataset.length;
507
- const newRows = this.mockData(1, lastRowIndex);
508
-
509
- // wrap into a timer to simulate a backend async call
510
- setTimeout(() => {
511
- const requisiteColumnDef = this.columnDefinitions.find((column: Column) => column.id === 'prerequisites');
512
- if (requisiteColumnDef) {
513
- const filterCollectionAsync = requisiteColumnDef.filter!.collectionAsync;
514
- const editorCollection = requisiteColumnDef.editor!.collection;
515
-
516
- if (Array.isArray(editorCollection)) {
517
- // add the new row to the grid
518
- this.angularGrid.gridService.addItem(newRows[0]);
519
-
520
- // then refresh the Editor "collection", we have 2 ways of doing it
521
-
522
- // Push to the Editor "collection"
523
- editorCollection.push({ value: lastRowIndex, label: lastRowIndex, prefix: 'Task' });
524
-
525
- // or replace entire "collection"
526
- // durationColumnDef.editor.collection = [...collection, ...[{ value: lastRowIndex, label: lastRowIndex }]];
527
-
528
- // for the Filter only, we have a trigger an RxJS/Subject change with the new collection
529
- // we do this because Filter(s) are shown at all time, while on Editor it's unnecessary since they are only shown when opening them
530
- if (filterCollectionAsync instanceof Subject) {
531
- filterCollectionAsync.next(editorCollection);
532
- }
533
- }
534
- }
535
- }, 250);
536
- }
537
-
538
- /**
539
- * Delete last inserted row.
540
- * Note that because Filter elements are always displayed on the screen, we need to tell the Filter,
541
- * we do this via a Subject .next(), that it's collection got changed
542
- * as for the Editor, there's nothing to do since the element is not shown and it will have latest collection next time it shows up
543
- */
544
- deleteItem() {
545
- const requisiteColumnDef = this.columnDefinitions.find((column: Column) => column.id === 'prerequisites');
546
- if (requisiteColumnDef) {
547
- const filterCollectionAsync = requisiteColumnDef.filter!.collectionAsync;
548
- const filterCollection = requisiteColumnDef.filter!.collection;
549
-
550
- if (Array.isArray(filterCollection)) {
551
- // sort collection in descending order and take out last collection option
552
- const selectCollectionObj = this.sortCollectionDescending(filterCollection).pop();
553
-
554
- // then we will delete that item from the grid
555
- this.angularGrid.gridService.deleteItemById(selectCollectionObj.value);
556
-
557
- // for the Filter only, we have a trigger an RxJS/Subject change with the new collection
558
- // we do this because Filter(s) are shown at all time, while on Editor it's unnecessary since they are only shown when opening them
559
- if (filterCollectionAsync instanceof Subject) {
560
- filterCollectionAsync.next(filterCollection);
561
- }
562
- }
563
- }
564
- }
565
-
566
- sortCollectionDescending(collection: any[]) {
567
- return collection.sort((item1, item2) => item1.value - item2.value);
568
- }
569
-
570
- mockData(itemCount: number, startingIndex = 0) {
571
- // mock a dataset
572
- const tempDataset = [];
573
- for (let i = startingIndex; i < (startingIndex + itemCount); i++) {
574
- const randomYear = 2000 + Math.floor(Math.random() * 10);
575
- const randomFinishYear = (new Date().getFullYear() - 3) + Math.floor(Math.random() * 10); // use only years not lower than 3 years ago
576
- const randomMonth = Math.floor(Math.random() * 11);
577
- const randomDay = Math.floor((Math.random() * 29));
578
- const randomPercent = Math.round(Math.random() * 100);
579
- const randomFinish = new Date(randomFinishYear, (randomMonth + 1), randomDay);
580
-
581
- tempDataset.push({
582
- id: i,
583
- title: 'Task ' + i,
584
- duration: (i % 33 === 0) ? null : Math.round(Math.random() * 100) + '',
585
- start: new Date(randomYear, randomMonth, randomDay),
586
- percentComplete: randomPercent,
587
- percentCompleteNumber: randomPercent,
588
- finish: randomFinish < new Date() ? '' : randomFinish, // make sure the random date is earlier than today
589
- effortDriven: (i % 5 === 0),
590
- prerequisites: (i % 2 === 0) && i !== 0 && i < 12 ? [i, i - 1] : [],
591
- countryOfOrigin: (i % 2) ? { code: 'CA', name: 'Canada' } : { code: 'US', name: 'United States' },
592
- countryOfOriginName: (i % 2) ? 'Canada' : 'United States',
593
- cityOfOrigin: (i % 2) ? 'Vancouver, BC, Canada' : 'Boston, MA, United States',
594
- });
595
- }
596
- return tempDataset;
597
- }
598
-
599
- onCellChanged(e: Event, args: any) {
600
- this.updatedObject = args.item;
601
- }
602
-
603
- onCellClicked(e: Event, args: any) {
604
- const metadata = this.angularGrid.gridService.getColumnFromEventArguments(args);
605
- console.log(metadata);
606
-
607
- if (metadata.columnDef.id === 'edit') {
608
- this.alertWarning = `open a modal window to edit: ${metadata.dataContext.title}`;
609
-
610
- // highlight the row, to customize the color, you can change the SASS variable $row-highlight-background-color
611
- this.angularGrid.gridService.highlightRow(args.row, 1500);
612
-
613
- // you could also select the row, when using "enableCellNavigation: true", it automatically selects the row
614
- // this.angularGrid.gridService.setSelectedRow(args.row);
615
- } else if (metadata.columnDef.id === 'delete') {
616
- if (confirm('Are you sure?')) {
617
- this.angularGrid.gridService.deleteItemById(metadata.dataContext.id);
618
- }
619
- }
620
- }
621
-
622
- onValidationError(e: Event, args: any) {
623
- if (args.validationResults) {
624
- alert(args.validationResults.msg);
625
- }
626
- }
627
-
628
- changeAutoCommit() {
629
- this.gridOptions.autoCommitEdit = !this.gridOptions.autoCommitEdit;
630
- this.gridObj.setOptions({
631
- autoCommitEdit: this.gridOptions.autoCommitEdit
632
- });
633
- return true;
634
- }
635
-
636
- dynamicallyAddTitleHeader() {
637
- const newCol = {
638
- id: `title${this.duplicateTitleHeaderCount++}`,
639
- name: 'Title',
640
- field: 'title',
641
- editor: {
642
- model: Editors.text,
643
- required: true,
644
- validator: myCustomTitleValidator, // use a custom validator
645
- },
646
- sortable: true, minWidth: 100, filterable: true,
647
- };
648
-
649
- // you can dynamically add your column to your column definitions
650
- // and then use the spread operator [...cols] OR slice to force Angular to review the changes
651
- this.columnDefinitions.push(newCol);
652
- this.columnDefinitions = this.columnDefinitions.slice(); // or use spread operator [...cols]
653
-
654
- // NOTE if you use an Extensions (Checkbox Selector, Row Detail, ...) that modifies the column definitions in any way
655
- // you MUST use "getAllColumnDefinitions()" from the GridService, using this will be ALL columns including the 1st column that is created internally
656
- // for example if you use the Checkbox Selector (row selection), you MUST use the code below
657
- /*
658
- const allColumns = this.angularGrid.gridService.getAllColumnDefinitions();
659
- allColumns.push(newCol);
660
- this.columnDefinitions = [...allColumns]; // (or use slice) reassign to column definitions for Angular to do dirty checking
661
- */
662
- }
663
-
664
- dynamicallyRemoveLastColumn() {
665
- this.columnDefinitions.pop();
666
- this.columnDefinitions = this.columnDefinitions.slice();
667
-
668
- // NOTE if you use an Extensions (Checkbox Selector, Row Detail, ...) that modifies the column definitions in any way
669
- // you MUST use the code below, first you must reassign the Editor facade (from the internalColumnEditor back to the editor)
670
- // in other words, SlickGrid is not using the same as Angular-Slickgrid uses (editor with a "model" and other properties are a facade, SlickGrid only uses what is inside the model)
671
- /*
672
- const allColumns = this.angularGrid.gridService.getAllColumnDefinitions();
673
- const allOriginalColumns = allColumns.map((column) => {
674
- column.editor = column.internalColumnEditor;
675
- return column;
676
- });
677
-
678
- // remove your column the full set of columns
679
- // and use slice or spread [...] to trigger an Angular dirty change
680
- allOriginalColumns.pop();
681
- this.columnDefinitions = allOriginalColumns.slice();
682
- */
683
- }
684
-
685
- setAutoEdit(isAutoEdit: boolean) {
686
- this.isAutoEdit = isAutoEdit;
687
- this.gridObj.setOptions({ autoEdit: isAutoEdit }); // change the grid option dynamically
688
- return true;
689
- }
690
-
691
- undo() {
692
- const command = this._commandQueue.pop();
693
- const item = this.angularGrid.dataView.getItem(command.row);
694
- if (command && Slick.GlobalEditorLock.cancelCurrentEdit()) {
695
- command.undo();
696
- this.gridObj.gotoCell(command.row, command.cell, false);
697
- }
698
- }
699
- }