angular-slickgrid 4.1.4 → 4.2.0

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 (242) hide show
  1. package/.browserslistrc +12 -0
  2. package/.codecov.yml +17 -0
  3. package/.editorconfig +18 -0
  4. package/.eslintrc.json +50 -0
  5. package/.github/CODE_OF_CONDUCT.md +76 -0
  6. package/.github/FUNDING.yml +8 -0
  7. package/.github/ISSUE_TEMPLATE/bug_report.yml +54 -0
  8. package/.github/ISSUE_TEMPLATE/config.yml +5 -0
  9. package/.github/ISSUE_TEMPLATE/feature_request.yml +44 -0
  10. package/.github/renovate.json5 +26 -0
  11. package/.github/stale.yml +7 -0
  12. package/.github/workflows/main.yml +83 -0
  13. package/.vscode/extensions.json +9 -0
  14. package/.vscode/launch.json +72 -0
  15. package/.vscode/settings.json +7 -0
  16. package/.vscode/tasks.json +77 -0
  17. package/CHANGELOG.md +1172 -0
  18. package/LICENSE +20 -20
  19. package/README.md +182 -180
  20. package/angular.json +148 -0
  21. package/dist/LICENSE +20 -0
  22. package/dist/README.md +182 -0
  23. package/{angular-slickgrid.d.ts → dist/angular-slickgrid.d.ts} +0 -0
  24. package/{app → dist/app}/modules/angular-slickgrid/components/angular-slickgrid.component.d.ts +0 -0
  25. package/{app → dist/app}/modules/angular-slickgrid/constants.d.ts +0 -0
  26. package/{app → dist/app}/modules/angular-slickgrid/extensions/index.d.ts +0 -0
  27. package/{app → dist/app}/modules/angular-slickgrid/extensions/slickRowDetailView.d.ts +0 -0
  28. package/{app → dist/app}/modules/angular-slickgrid/global-grid-options.d.ts +0 -0
  29. package/{app → dist/app}/modules/angular-slickgrid/index.d.ts +0 -0
  30. package/{app → dist/app}/modules/angular-slickgrid/models/angularComponentOutput.interface.d.ts +0 -0
  31. package/{app → dist/app}/modules/angular-slickgrid/models/angularGridInstance.interface.d.ts +0 -0
  32. package/{app → dist/app}/modules/angular-slickgrid/models/externalTestingDependencies.interface.d.ts +0 -0
  33. package/{app → dist/app}/modules/angular-slickgrid/models/gridOption.interface.d.ts +0 -0
  34. package/{app → dist/app}/modules/angular-slickgrid/models/index.d.ts +0 -0
  35. package/{app → dist/app}/modules/angular-slickgrid/models/rowDetailView.interface.d.ts +0 -0
  36. package/{app → dist/app}/modules/angular-slickgrid/models/slickGrid.interface.d.ts +0 -0
  37. package/{app → dist/app}/modules/angular-slickgrid/modules/angular-slickgrid.module.d.ts +0 -0
  38. package/{app → dist/app}/modules/angular-slickgrid/services/angularUtil.service.d.ts +0 -0
  39. package/{app → dist/app}/modules/angular-slickgrid/services/bsDropdown.service.d.ts +0 -0
  40. package/{app → dist/app}/modules/angular-slickgrid/services/container.service.d.ts +0 -0
  41. package/{app → dist/app}/modules/angular-slickgrid/services/index.d.ts +0 -0
  42. package/{app → dist/app}/modules/angular-slickgrid/services/translater.service.d.ts +0 -0
  43. package/{app → dist/app}/modules/angular-slickgrid/services/utilities.d.ts +0 -0
  44. package/{app → dist/app}/modules/angular-slickgrid/slickgrid-config.d.ts +0 -0
  45. package/{esm2020 → dist/esm2020}/angular-slickgrid.mjs +0 -0
  46. package/dist/esm2020/app/modules/angular-slickgrid/components/angular-slickgrid.component.mjs +1171 -0
  47. package/{esm2020 → dist/esm2020}/app/modules/angular-slickgrid/constants.mjs +1 -1
  48. package/{esm2020 → dist/esm2020}/app/modules/angular-slickgrid/extensions/index.mjs +1 -1
  49. package/{esm2020 → dist/esm2020}/app/modules/angular-slickgrid/extensions/slickRowDetailView.mjs +2 -2
  50. package/{esm2020 → dist/esm2020}/app/modules/angular-slickgrid/global-grid-options.mjs +1 -1
  51. package/{esm2020 → dist/esm2020}/app/modules/angular-slickgrid/index.mjs +1 -1
  52. package/{esm2020 → dist/esm2020}/app/modules/angular-slickgrid/models/angularComponentOutput.interface.mjs +1 -1
  53. package/dist/esm2020/app/modules/angular-slickgrid/models/angularGridInstance.interface.mjs +2 -0
  54. package/dist/esm2020/app/modules/angular-slickgrid/models/externalTestingDependencies.interface.mjs +2 -0
  55. package/dist/esm2020/app/modules/angular-slickgrid/models/gridOption.interface.mjs +2 -0
  56. package/{esm2020 → dist/esm2020}/app/modules/angular-slickgrid/models/index.mjs +1 -1
  57. package/dist/esm2020/app/modules/angular-slickgrid/models/rowDetailView.interface.mjs +2 -0
  58. package/dist/esm2020/app/modules/angular-slickgrid/models/slickGrid.interface.mjs +2 -0
  59. package/{esm2020 → dist/esm2020}/app/modules/angular-slickgrid/modules/angular-slickgrid.module.mjs +5 -5
  60. package/{esm2020 → dist/esm2020}/app/modules/angular-slickgrid/services/angularUtil.service.mjs +4 -4
  61. package/{esm2020 → dist/esm2020}/app/modules/angular-slickgrid/services/bsDropdown.service.mjs +4 -4
  62. package/{esm2020 → dist/esm2020}/app/modules/angular-slickgrid/services/container.service.mjs +4 -4
  63. package/{esm2020 → dist/esm2020}/app/modules/angular-slickgrid/services/index.mjs +1 -1
  64. package/{esm2020 → dist/esm2020}/app/modules/angular-slickgrid/services/translater.service.mjs +4 -4
  65. package/{esm2020 → dist/esm2020}/app/modules/angular-slickgrid/services/utilities.mjs +1 -1
  66. package/{esm2020 → dist/esm2020}/app/modules/angular-slickgrid/slickgrid-config.mjs +1 -1
  67. package/{esm2020 → dist/esm2020}/public_api.mjs +1 -1
  68. package/{fesm2015 → dist/fesm2015}/angular-slickgrid.mjs +25 -22
  69. package/dist/fesm2015/angular-slickgrid.mjs.map +1 -0
  70. package/{fesm2020 → dist/fesm2020}/angular-slickgrid.mjs +25 -22
  71. package/dist/fesm2020/angular-slickgrid.mjs.map +1 -0
  72. package/{i18n → dist/i18n}/en.json +89 -89
  73. package/{i18n → dist/i18n}/fr.json +90 -90
  74. package/dist/package.json +79 -0
  75. package/{public_api.d.ts → dist/public_api.d.ts} +0 -0
  76. package/global.d.ts +1 -0
  77. package/ngcc.config.js +13 -0
  78. package/package.json +121 -37
  79. package/screenshots/column-picker.png +0 -0
  80. package/screenshots/composite-editor.png +0 -0
  81. package/screenshots/draggable-grouping.png +0 -0
  82. package/screenshots/editors.png +0 -0
  83. package/screenshots/export-to-file.png +0 -0
  84. package/screenshots/filter_and_sort.png +0 -0
  85. package/screenshots/formatters.png +0 -0
  86. package/screenshots/frozen.png +0 -0
  87. package/screenshots/multipleSelectFilter.png +0 -0
  88. package/screenshots/pagination.png +0 -0
  89. package/screenshots/selectFilter.png +0 -0
  90. package/screenshots/singleFilter.png +0 -0
  91. package/src/app/app-routing.module.ts +83 -0
  92. package/src/app/app.component.html +160 -0
  93. package/src/app/app.component.scss +65 -0
  94. package/src/app/app.component.ts +10 -0
  95. package/src/app/app.module.ts +175 -0
  96. package/src/app/examples/custom-angularComponentEditor.ts +184 -0
  97. package/src/app/examples/custom-angularComponentFilter.ts +126 -0
  98. package/src/app/examples/custom-inputEditor.ts +124 -0
  99. package/src/app/examples/custom-inputFilter.ts +142 -0
  100. package/src/app/examples/custom-titleFormatter.component.ts +8 -0
  101. package/src/app/examples/editor-ng-select.component.ts +37 -0
  102. package/src/app/examples/filter-ng-select.component.ts +32 -0
  103. package/src/app/examples/grid-additem.component.html +48 -0
  104. package/src/app/examples/grid-additem.component.ts +272 -0
  105. package/src/app/examples/grid-angular.component.html +79 -0
  106. package/src/app/examples/grid-angular.component.scss +28 -0
  107. package/src/app/examples/grid-angular.component.ts +370 -0
  108. package/src/app/examples/grid-autoheight.component.html +52 -0
  109. package/src/app/examples/grid-autoheight.component.ts +147 -0
  110. package/src/app/examples/grid-basic.component.html +29 -0
  111. package/src/app/examples/grid-basic.component.ts +82 -0
  112. package/src/app/examples/grid-clientside.component.html +51 -0
  113. package/src/app/examples/grid-clientside.component.ts +293 -0
  114. package/src/app/examples/grid-colspan.component.html +39 -0
  115. package/src/app/examples/grid-colspan.component.scss +11 -0
  116. package/src/app/examples/grid-colspan.component.ts +155 -0
  117. package/src/app/examples/grid-composite-editor.component.html +79 -0
  118. package/src/app/examples/grid-composite-editor.component.scss +19 -0
  119. package/src/app/examples/grid-composite-editor.component.ts +948 -0
  120. package/src/app/examples/grid-contextmenu.component.html +62 -0
  121. package/src/app/examples/grid-contextmenu.component.scss +44 -0
  122. package/src/app/examples/grid-contextmenu.component.ts +473 -0
  123. package/src/app/examples/grid-custom-tooltip.component.html +25 -0
  124. package/src/app/examples/grid-custom-tooltip.component.scss +77 -0
  125. package/src/app/examples/grid-custom-tooltip.component.ts +483 -0
  126. package/src/app/examples/grid-draggrouping.component.html +93 -0
  127. package/src/app/examples/grid-draggrouping.component.ts +397 -0
  128. package/src/app/examples/grid-editor.component.html +88 -0
  129. package/src/app/examples/grid-editor.component.ts +699 -0
  130. package/src/app/examples/grid-formatter.component.html +26 -0
  131. package/src/app/examples/grid-formatter.component.ts +162 -0
  132. package/src/app/examples/grid-frozen.component.html +65 -0
  133. package/src/app/examples/grid-frozen.component.scss +11 -0
  134. package/src/app/examples/grid-frozen.component.ts +303 -0
  135. package/src/app/examples/grid-graphql-nopage.component.html +33 -0
  136. package/src/app/examples/grid-graphql-nopage.component.scss +9 -0
  137. package/src/app/examples/grid-graphql-nopage.component.ts +242 -0
  138. package/src/app/examples/grid-graphql.component.html +87 -0
  139. package/src/app/examples/grid-graphql.component.ts +304 -0
  140. package/src/app/examples/grid-grouping.component.html +80 -0
  141. package/src/app/examples/grid-grouping.component.ts +313 -0
  142. package/src/app/examples/grid-headerbutton.component.html +31 -0
  143. package/src/app/examples/grid-headerbutton.component.scss +10 -0
  144. package/src/app/examples/grid-headerbutton.component.ts +233 -0
  145. package/src/app/examples/grid-headermenu.component.html +31 -0
  146. package/src/app/examples/grid-headermenu.component.scss +25 -0
  147. package/src/app/examples/grid-headermenu.component.ts +159 -0
  148. package/src/app/examples/grid-localization.component.html +54 -0
  149. package/src/app/examples/grid-localization.component.ts +293 -0
  150. package/src/app/examples/grid-menu.component.html +37 -0
  151. package/src/app/examples/grid-menu.component.scss +28 -0
  152. package/src/app/examples/grid-menu.component.ts +229 -0
  153. package/src/app/examples/grid-odata.component.html +116 -0
  154. package/src/app/examples/grid-odata.component.ts +441 -0
  155. package/src/app/examples/grid-range.component.html +74 -0
  156. package/src/app/examples/grid-range.component.ts +291 -0
  157. package/src/app/examples/grid-remote.component.html +37 -0
  158. package/src/app/examples/grid-remote.component.ts +153 -0
  159. package/src/app/examples/grid-resize-by-content.component.html +62 -0
  160. package/src/app/examples/grid-resize-by-content.component.scss +19 -0
  161. package/src/app/examples/grid-resize-by-content.component.ts +780 -0
  162. package/src/app/examples/grid-rowdetail.component.html +35 -0
  163. package/src/app/examples/grid-rowdetail.component.ts +205 -0
  164. package/src/app/examples/grid-rowmove.component.html +49 -0
  165. package/src/app/examples/grid-rowmove.component.ts +234 -0
  166. package/src/app/examples/grid-rowselection.component.html +76 -0
  167. package/src/app/examples/grid-rowselection.component.ts +267 -0
  168. package/src/app/examples/grid-state.component.html +36 -0
  169. package/src/app/examples/grid-state.component.ts +259 -0
  170. package/src/app/examples/grid-tabs.component.html +35 -0
  171. package/src/app/examples/grid-tabs.component.ts +115 -0
  172. package/src/app/examples/grid-trading.component.html +58 -0
  173. package/src/app/examples/grid-trading.component.scss +49 -0
  174. package/src/app/examples/grid-trading.component.ts +319 -0
  175. package/src/app/examples/grid-tree-data-hierarchical.component.html +79 -0
  176. package/src/app/examples/grid-tree-data-hierarchical.component.scss +47 -0
  177. package/src/app/examples/grid-tree-data-hierarchical.component.ts +311 -0
  178. package/src/app/examples/grid-tree-data-parent-child.component.html +108 -0
  179. package/src/app/examples/grid-tree-data-parent-child.component.scss +10 -0
  180. package/src/app/examples/grid-tree-data-parent-child.component.ts +351 -0
  181. package/src/app/examples/home.component.html +41 -0
  182. package/src/app/examples/home.component.ts +9 -0
  183. package/src/app/examples/rowdetail-preload.component.ts +10 -0
  184. package/src/app/examples/rowdetail-view.component.html +36 -0
  185. package/src/app/examples/rowdetail-view.component.ts +54 -0
  186. package/src/app/examples/swt-common-grid-pagination.component.ts +156 -0
  187. package/src/app/examples/swt-common-grid-test.component.html +30 -0
  188. package/src/app/examples/swt-common-grid-test.component.ts +219 -0
  189. package/src/app/examples/swt-common-grid.component.ts +436 -0
  190. package/src/app/examples/swt-logger.service.ts +165 -0
  191. package/src/app/modules/angular-slickgrid/components/angular-slickgrid.component.html +4 -0
  192. package/src/app/modules/angular-slickgrid/components/angular-slickgrid.component.ts +1395 -0
  193. package/src/app/modules/angular-slickgrid/constants.ts +97 -0
  194. package/src/app/modules/angular-slickgrid/extensions/index.ts +1 -0
  195. package/src/app/modules/angular-slickgrid/extensions/slickRowDetailView.ts +375 -0
  196. package/src/app/modules/angular-slickgrid/global-grid-options.ts +245 -0
  197. package/src/app/modules/angular-slickgrid/index.ts +11 -0
  198. package/src/app/modules/angular-slickgrid/models/angularComponentOutput.interface.ts +6 -0
  199. package/src/app/modules/angular-slickgrid/models/angularGridInstance.interface.ts +68 -0
  200. package/src/app/modules/angular-slickgrid/models/externalTestingDependencies.interface.ts +37 -0
  201. package/src/app/modules/angular-slickgrid/models/gridOption.interface.ts +12 -0
  202. package/src/app/modules/angular-slickgrid/models/index.ts +6 -0
  203. package/src/app/modules/angular-slickgrid/models/rowDetailView.interface.ts +33 -0
  204. package/src/app/modules/angular-slickgrid/models/slickGrid.interface.ts +7 -0
  205. package/src/app/modules/angular-slickgrid/modules/angular-slickgrid.module.ts +37 -0
  206. package/src/app/modules/angular-slickgrid/services/angularUtil.service.ts +48 -0
  207. package/src/app/modules/angular-slickgrid/services/bsDropdown.service.ts +142 -0
  208. package/src/app/modules/angular-slickgrid/services/container.service.ts +24 -0
  209. package/src/app/modules/angular-slickgrid/services/index.ts +5 -0
  210. package/src/app/modules/angular-slickgrid/services/translater.service.ts +38 -0
  211. package/src/app/modules/angular-slickgrid/services/utilities.ts +19 -0
  212. package/src/app/modules/angular-slickgrid/slickgrid-config.ts +10 -0
  213. package/src/app/slickgrid-custom-variables.scss +10 -0
  214. package/src/assets/.gitkeep +0 -0
  215. package/src/assets/data/collection_100_numbers.json +12 -0
  216. package/src/assets/data/collection_500_numbers.json +52 -0
  217. package/src/assets/data/countries.json +245 -0
  218. package/src/assets/data/country_names.json +245 -0
  219. package/src/assets/data/customers_100.json +102 -0
  220. package/src/assets/i18n/en.json +90 -0
  221. package/src/assets/i18n/fr.json +91 -0
  222. package/src/environments/environment.prod.ts +3 -0
  223. package/src/environments/environment.ts +8 -0
  224. package/src/favicon.ico +0 -0
  225. package/src/index.html +18 -0
  226. package/src/main.ts +13 -0
  227. package/src/polyfills.ts +52 -0
  228. package/src/public_api.ts +1 -0
  229. package/src/styles.scss +66 -0
  230. package/src/typings.d.ts +10 -0
  231. package/tsconfig.app.json +25 -0
  232. package/tsconfig.json +40 -0
  233. package/tsconfig.spec.json +23 -0
  234. package/docs/assets/lib/multiple-select/README.md +0 -17
  235. package/esm2020/app/modules/angular-slickgrid/components/angular-slickgrid.component.mjs +0 -1168
  236. package/esm2020/app/modules/angular-slickgrid/models/angularGridInstance.interface.mjs +0 -2
  237. package/esm2020/app/modules/angular-slickgrid/models/externalTestingDependencies.interface.mjs +0 -2
  238. package/esm2020/app/modules/angular-slickgrid/models/gridOption.interface.mjs +0 -2
  239. package/esm2020/app/modules/angular-slickgrid/models/rowDetailView.interface.mjs +0 -2
  240. package/esm2020/app/modules/angular-slickgrid/models/slickGrid.interface.mjs +0 -2
  241. package/fesm2015/angular-slickgrid.mjs.map +0 -1
  242. package/fesm2020/angular-slickgrid.mjs.map +0 -1
@@ -0,0 +1,370 @@
1
+ import { Component, OnInit, ViewEncapsulation } from '@angular/core';
2
+ import { TranslateService } from '@ngx-translate/core';
3
+
4
+ import {
5
+ AngularGridInstance,
6
+ AngularUtilService,
7
+ BsDropDownService,
8
+ Column,
9
+ Editors,
10
+ FieldType,
11
+ Filters,
12
+ Formatters,
13
+ GridOption,
14
+ OnEventArgs,
15
+ SlickNamespace,
16
+ } from './../modules/angular-slickgrid';
17
+ import { EditorNgSelectComponent } from './editor-ng-select.component';
18
+ import { CustomAngularComponentEditor } from './custom-angularComponentEditor';
19
+ import { CustomAngularComponentFilter } from './custom-angularComponentFilter';
20
+ import { CustomTitleFormatterComponent } from './custom-titleFormatter.component';
21
+ import { FilterNgSelectComponent } from './filter-ng-select.component';
22
+
23
+ // using external non-typed js libraries
24
+ declare const Slick: SlickNamespace;
25
+ declare const $: any;
26
+
27
+ const NB_ITEMS = 100;
28
+
29
+ @Component({
30
+ templateUrl: './grid-angular.component.html',
31
+ styleUrls: ['./grid-angular.component.scss'],
32
+ encapsulation: ViewEncapsulation.None
33
+ })
34
+ export class GridAngularComponent implements OnInit {
35
+ title = 'Example 22: Use of Angular Components';
36
+ subTitle = `
37
+ <h3>Filters, Editors, AsyncPostRender with Angular Components</h3>
38
+ Grid with usage of Angular Components as Editor &amp; AsyncPostRender (similar to Formatter).
39
+ <ul>
40
+ <li>Support of Angular Component as Custom Editor (click on any "Assignee" name cell)</li>
41
+ <ul>
42
+ <li>That column uses <a href="https://github.com/ng-select/ng-select" target="_blank">ng-select</a> as a custom editor as an Angular Component
43
+ <li>Increased Grid Options "rowHeight" &amp; "headerRowHeight" to 45 so that the "ng-select" fits in the cell. Ideally it would be better to override the ng-select css styling to change it's max height</li>
44
+ </ul>
45
+ <li>Support of Angular Component as Custom Filter ("Assignee" columns), which also uses "ng-select"
46
+ <li>The 2nd "Assignee" column (showing in bold text) uses "asyncPostRender" with an Angular Component</li>
47
+ <ul>
48
+ <li>Why can't we use Angular Component as Customer Formatter and why do I see a slight delay in loading the data?</li>
49
+ <li>It's totally normal since SlickGrid Formatters only accept strings (synchronously),
50
+ so we cannot use that (Angular requires at least 1 full cycle to render the element), so we are left with SlickGrid "asyncPostRender" and
51
+ it works but as the name suggest it's async users might see noticeable delay in loading the data
52
+ </li>
53
+ </ul>
54
+ </ul>
55
+ `;
56
+
57
+ private _commandQueue: any[] = [];
58
+ angularGrid!: AngularGridInstance;
59
+ columnDefinitions: Column[] = [];
60
+ gridOptions!: GridOption;
61
+ dataset!: any[];
62
+ gridObj: any;
63
+ isAutoEdit = true;
64
+ alertWarning: any;
65
+ updatedObject: any;
66
+ selectedLanguage = 'en';
67
+ assignees = [
68
+ { id: '', name: '' },
69
+ { id: '1', name: 'John' },
70
+ { id: '2', name: 'Pierre' },
71
+ { id: '3', name: 'Paul' },
72
+ ];
73
+
74
+ constructor(private angularUtilService: AngularUtilService, private bsDropdown: BsDropDownService, private translate: TranslateService) { }
75
+
76
+ ngOnInit(): void {
77
+ this.prepareGrid();
78
+ }
79
+
80
+ angularGridReady(angularGrid: AngularGridInstance) {
81
+ this.angularGrid = angularGrid;
82
+ this.gridObj = angularGrid.slickGrid;
83
+ }
84
+
85
+ prepareGrid() {
86
+ this.columnDefinitions = [
87
+ {
88
+ id: 'title',
89
+ name: 'Title',
90
+ field: 'title',
91
+ minWidth: 100,
92
+ filterable: true,
93
+ sortable: true,
94
+ type: FieldType.string,
95
+ editor: {
96
+ model: Editors.longText,
97
+ minLength: 5,
98
+ maxLength: 255,
99
+ },
100
+ onCellChange: (e: Event, args: OnEventArgs) => {
101
+ console.log(args);
102
+ this.alertWarning = `Updated Title: ${args.dataContext.title}`;
103
+ }
104
+ }, {
105
+ id: 'assignee',
106
+ name: 'Assignee',
107
+ field: 'assignee',
108
+ minWidth: 100,
109
+ filterable: true,
110
+ sortable: true,
111
+ filter: {
112
+ model: new CustomAngularComponentFilter(), // create a new instance to make each Filter independent from each other
113
+ collection: this.assignees,
114
+ params: {
115
+ component: FilterNgSelectComponent,
116
+ }
117
+ },
118
+ queryFieldFilter: 'assignee.id', // for a complex object it's important to tell the Filter which field to query and our CustomAngularComponentFilter returns the "id" property
119
+ queryFieldSorter: 'assignee.name',
120
+ formatter: Formatters.complexObject,
121
+ params: {
122
+ complexFieldLabel: 'assignee.name',
123
+ },
124
+ exportWithFormatter: true,
125
+ editor: {
126
+ model: CustomAngularComponentEditor,
127
+ collection: this.assignees,
128
+ params: {
129
+ component: EditorNgSelectComponent,
130
+ }
131
+ },
132
+ onCellChange: (e: Event, args: OnEventArgs) => {
133
+ console.log(args);
134
+ this.alertWarning = `Updated Title: ${args.dataContext.title}`;
135
+ }
136
+ }, {
137
+ id: 'assignee2',
138
+ name: 'Assignee with Angular Component',
139
+ field: 'assignee',
140
+ minWidth: 125,
141
+ filterable: true,
142
+ sortable: true,
143
+ filter: {
144
+ model: new CustomAngularComponentFilter(), // create a new instance to make each Filter independent from each other
145
+ collection: this.assignees,
146
+ params: {
147
+ component: FilterNgSelectComponent,
148
+ }
149
+ },
150
+ queryFieldFilter: 'assignee.id', // for a complex object it's important to tell the Filter which field to query and our CustomAngularComponentFilter returns the "id" property
151
+ queryFieldSorter: 'assignee.name',
152
+
153
+ // loading formatter, text to display while Post Render gets processed
154
+ formatter: () => '...',
155
+
156
+ // to load an Angular Component, you cannot use a Formatter since Angular needs at least 1 cycle to render everything
157
+ // you can use a PostRenderer but you will visually see the data appearing,
158
+ // which is why it's still better to use regular Formatter (with jQuery if need be) instead of Angular Component
159
+ asyncPostRender: this.renderAngularComponent.bind(this),
160
+ params: {
161
+ component: CustomTitleFormatterComponent,
162
+ angularUtilService: this.angularUtilService,
163
+ complexFieldLabel: 'assignee.name' // for the exportCustomFormatter
164
+ },
165
+ exportCustomFormatter: Formatters.complexObject,
166
+ }, {
167
+ id: 'complete',
168
+ name: '% Complete',
169
+ field: 'percentComplete',
170
+ minWidth: 100,
171
+ filterable: true,
172
+ formatter: Formatters.multiple,
173
+ type: FieldType.number,
174
+ editor: {
175
+ model: Editors.singleSelect,
176
+
177
+ // 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
178
+ enableRenderHtml: true,
179
+ collection: Array.from(Array(101).keys()).map(k => ({ value: k, label: k, symbol: '<i class="fa fa-percent" style="color:cadetblue"></i>' })),
180
+ customStructure: {
181
+ value: 'value',
182
+ label: 'label',
183
+ labelSuffix: 'symbol'
184
+ },
185
+ editorOptions: {
186
+ maxHeight: 400
187
+ }
188
+ },
189
+ filter: {
190
+ model: Filters.slider,
191
+ operator: '>=',
192
+ params: { hideSliderNumber: false }
193
+ },
194
+ params: {
195
+ formatters: [Formatters.collectionEditor, Formatters.percentCompleteBar],
196
+ }
197
+ }, {
198
+ id: 'start',
199
+ name: 'Start',
200
+ field: 'start',
201
+ minWidth: 100,
202
+ filterable: true,
203
+ filter: { model: Filters.compoundDate },
204
+ formatter: Formatters.dateIso,
205
+ exportWithFormatter: true,
206
+ sortable: true,
207
+ type: FieldType.date,
208
+ editor: {
209
+ model: Editors.date
210
+ },
211
+ }, {
212
+ id: 'finish',
213
+ name: 'Finish',
214
+ field: 'finish',
215
+ minWidth: 100,
216
+ filterable: true,
217
+ sortable: true,
218
+ filter: { model: Filters.compoundDate },
219
+ formatter: Formatters.dateIso,
220
+ exportWithFormatter: true,
221
+ type: FieldType.date,
222
+ editor: {
223
+ model: Editors.date
224
+ },
225
+ },
226
+ {
227
+ id: 'action',
228
+ name: 'Action',
229
+ field: 'id',
230
+ formatter: () => `<div class="fake-hyperlink">Action <i class="fa fa-caret-down"></i></div>`,
231
+ cellMenu: {
232
+ commandTitle: 'Commands',
233
+ commandItems: [
234
+ {
235
+ command: 'help',
236
+ title: 'Help',
237
+ iconCssClass: 'fa fa-question-circle text-info',
238
+ positionOrder: 66,
239
+ action: () => alert('Please Help!'),
240
+ },
241
+ {
242
+ command: 'delete-row', title: 'Delete Row', positionOrder: 64,
243
+ iconCssClass: 'fa fa-times color-danger', cssClass: 'red', textCssClass: 'text-italic color-danger-light',
244
+ action: (_event, args) => this.angularGrid.gridService.deleteItemById(args.dataContext.id)
245
+ },
246
+ ]
247
+ }
248
+ }
249
+ ];
250
+
251
+ this.gridOptions = {
252
+ asyncEditorLoading: false,
253
+ autoEdit: this.isAutoEdit,
254
+ autoCommitEdit: false,
255
+ autoResize: {
256
+ container: '#demo-container',
257
+ rightPadding: 10
258
+ },
259
+ headerRowHeight: 45,
260
+ rowHeight: 45, // increase row height so that the ng-select fits in the cell
261
+ editable: true,
262
+ enableCellMenu: true,
263
+ enableCellNavigation: true,
264
+ enableColumnPicker: true,
265
+ enableExcelCopyBuffer: true,
266
+ enableFiltering: true,
267
+ enableAsyncPostRender: true, // for the Angular PostRenderer, don't forget to enable it
268
+ asyncPostRenderDelay: 0, // also make sure to remove any delay to render it
269
+ editCommandHandler: (item, column, editCommand) => {
270
+ this._commandQueue.push(editCommand);
271
+ editCommand.execute();
272
+ },
273
+ i18n: this.translate,
274
+ params: {
275
+ angularUtilService: this.angularUtilService // provide the service to all at once (Editor, Filter, AsyncPostRender)
276
+ }
277
+ };
278
+
279
+ this.dataset = this.mockData(NB_ITEMS);
280
+ }
281
+
282
+ mockData(itemCount: number, startingIndex = 0) {
283
+ // mock a dataset
284
+ const tempDataset = [];
285
+ for (let i = startingIndex; i < (startingIndex + itemCount); i++) {
286
+ const randomYear = 2000 + Math.floor(Math.random() * 10);
287
+ const randomMonth = Math.floor(Math.random() * 11);
288
+ const randomDay = Math.floor((Math.random() * 29));
289
+ const randomPercent = Math.round(Math.random() * 100);
290
+
291
+ tempDataset.push({
292
+ id: i,
293
+ title: 'Task ' + i,
294
+ assignee: i % 3 ? this.assignees[3] : i % 2 ? this.assignees[2] : this.assignees[1],
295
+ duration: Math.round(Math.random() * 100) + '',
296
+ percentComplete: randomPercent,
297
+ percentCompleteNumber: randomPercent,
298
+ start: new Date(randomYear, randomMonth, randomDay),
299
+ finish: new Date(randomYear, (randomMonth + 1), randomDay),
300
+ effortDriven: (i % 5 === 0),
301
+ });
302
+ }
303
+ return tempDataset;
304
+ }
305
+
306
+ onCellChanged(e: Event, args: any) {
307
+ this.updatedObject = args.item;
308
+ }
309
+
310
+ onCellClicked(e: Event, args: any) {
311
+ const metadata = this.angularGrid.gridService.getColumnFromEventArguments(args);
312
+ console.log(metadata);
313
+
314
+ if (metadata.columnDef.id === 'edit') {
315
+ this.alertWarning = `open a modal window to edit: ${metadata.dataContext.title}`;
316
+
317
+ // highlight the row, to customize the color, you can change the SASS variable $row-highlight-background-color
318
+ this.angularGrid.gridService.highlightRow(args.row, 1500);
319
+
320
+ // you could also select the row, when using "enableCellNavigation: true", it automatically selects the row
321
+ // this.angularGrid.gridService.setSelectedRow(args.row);
322
+ } else if (metadata.columnDef.id === 'delete') {
323
+ if (confirm('Are you sure?')) {
324
+ this.angularGrid.gridService.deleteItemById(metadata.dataContext.id);
325
+ }
326
+ }
327
+ }
328
+
329
+ onCellValidationError(e: Event, args: any) {
330
+ alert(args.validationResults.msg);
331
+ }
332
+
333
+ changeAutoCommit() {
334
+ this.gridOptions.autoCommitEdit = !this.gridOptions.autoCommitEdit;
335
+ this.gridObj.setOptions({
336
+ autoCommitEdit: this.gridOptions.autoCommitEdit
337
+ });
338
+ return true;
339
+ }
340
+
341
+ setAutoEdit(isAutoEdit: boolean) {
342
+ this.isAutoEdit = isAutoEdit;
343
+ this.gridObj.setOptions({ autoEdit: isAutoEdit }); // change the grid option dynamically
344
+ return true;
345
+ }
346
+
347
+ undo() {
348
+ const command = this._commandQueue.pop();
349
+ if (command && Slick.GlobalEditorLock.cancelCurrentEdit()) {
350
+ command.undo();
351
+ this.gridObj.gotoCell(command.row, command.cell, false);
352
+ }
353
+ }
354
+
355
+ renderAngularComponent(cellNode: HTMLElement, row: number, dataContext: any, colDef: Column) {
356
+ if (colDef.params.component) {
357
+ const componentOutput = this.angularUtilService.createAngularComponent(colDef.params.component);
358
+ Object.assign(componentOutput.componentRef.instance, { item: dataContext });
359
+
360
+ // use a delay to make sure Angular ran at least a full cycle and make sure it finished rendering the Component
361
+ setTimeout(() => $(cellNode).empty().html(componentOutput.domElement));
362
+ }
363
+ }
364
+
365
+ /* Create an Action Dropdown Menu */
366
+ deleteCell(rowNumber: number) {
367
+ const item = this.angularGrid.dataView.getItem(rowNumber);
368
+ this.angularGrid.gridService.deleteItemById(item.id);
369
+ }
370
+ }
@@ -0,0 +1,52 @@
1
+ <div class="container-fluid">
2
+ <h2>
3
+ {{title}}
4
+ <span class="float-end">
5
+ <a style="font-size: 18px"
6
+ target="_blank"
7
+ href="https://github.com/ghiscoding/Angular-Slickgrid/blob/master/src/app/examples/grid-autoheight.component.ts">
8
+ <span class="fa fa-link"></span> code
9
+ </a>
10
+ </span>
11
+ </h2>
12
+ <div class="subtitle" [innerHTML]="subTitle"></div>
13
+
14
+ <div class="row row-cols-lg-auto g-1 align-items-center">
15
+ <div class="col">
16
+ <label for="columnSelect">Single Search:</label>
17
+ </div>
18
+ <div class="col">
19
+ <select class="form-select" class="form-select" data-test="search-column-list" name="selectedColumn"
20
+ [(ngModel)]="selectedColumn"
21
+ (ngModelChange)="updateFilter()">
22
+ <option [ngValue]="field" *ngFor="let field of columnDefinitions">{{field.name}}</option>
23
+ </select>
24
+ </div>
25
+ <div class="col">
26
+ <select class="form-select" data-test="search-operator-list" name="selectedOperator"
27
+ [(ngModel)]="selectedOperator" (ngModelChange)="updateFilter()">
28
+ <option [ngValue]="operator" *ngFor="let operator of operatorList">{{operator}}</option>
29
+ </select>
30
+ </div>
31
+
32
+ <div class="col">
33
+ <div class="input-group">
34
+ <input type="text" class="form-control" data-test="search-value-input" name="searchValue"
35
+ placeholder="search value" autocomplete="off" (input)="updateFilter()" [(ngModel)]="searchValue">
36
+ <button class="btn btn-outline-secondary d-flex align-items-center pl-2 pr-2" data-test="clear-search-value"
37
+ (click)="cleargridSearchInput()">
38
+ <span class="fa fa-times"></span>
39
+ </button>
40
+ </div>
41
+ </div>
42
+ </div>
43
+
44
+ <hr />
45
+
46
+ <angular-slickgrid gridId="grid23"
47
+ [columnDefinitions]="columnDefinitions"
48
+ [gridOptions]="gridOptions"
49
+ [dataset]="dataset"
50
+ (onAngularGridCreated)="angularGridReady($event.detail)">
51
+ </angular-slickgrid>
52
+ </div>
@@ -0,0 +1,147 @@
1
+ import { Component, OnInit, ViewEncapsulation } from '@angular/core';
2
+ import {
3
+ AngularGridInstance,
4
+ Column,
5
+ FieldType,
6
+ Formatters,
7
+ GridOption,
8
+ OperatorString,
9
+ SlickDataView,
10
+ SlickGrid,
11
+ } from './../modules/angular-slickgrid';
12
+
13
+ @Component({
14
+ styles: ['.duration-bg { background-color: #e9d4f1 !important }'],
15
+ encapsulation: ViewEncapsulation.None,
16
+ templateUrl: './grid-autoheight.component.html'
17
+ })
18
+ export class GridAutoHeightComponent implements OnInit {
19
+ title = 'Example 23: Grid AutoHeight';
20
+ subTitle = `
21
+ The SlickGrid option "autoHeight" can be used if you wish to keep the full height of the grid without any scrolling
22
+ <ul>
23
+ <li>You define a fixed grid width via "gridWidth" in the View</li>
24
+ <li>You can still use the "autoResize" for the width to be resized automatically (the height will never change in this case)</li>
25
+ <li>This dataset has 25 rows, if you scroll down the page you can see the entire set is shown without any grid scrolling (though you might have browser scrolling)</li>
26
+ </ul>
27
+ `;
28
+
29
+ angularGrid!: AngularGridInstance;
30
+ grid!: SlickGrid;
31
+ dataView!: SlickDataView;
32
+ columnDefinitions: Column[] = [];
33
+ gridOptions!: GridOption;
34
+ dataset!: any[];
35
+ operatorList: OperatorString[] = ['=', '<', '<=', '>', '>=', '<>', 'StartsWith', 'EndsWith'];
36
+ selectedOperator = '=';
37
+ searchValue = '';
38
+ selectedColumn?: Column;
39
+
40
+ constructor() { }
41
+
42
+ ngOnInit() {
43
+ this.prepareGrid();
44
+ }
45
+
46
+ angularGridReady(angularGrid: AngularGridInstance) {
47
+ this.angularGrid = angularGrid;
48
+ }
49
+
50
+ prepareGrid() {
51
+ this.columnDefinitions = [
52
+ {
53
+ id: 'title', name: 'Title', field: 'title',
54
+ sortable: true,
55
+ type: FieldType.string
56
+ },
57
+ {
58
+ id: 'duration', name: 'Duration (days)', field: 'duration',
59
+ sortable: true,
60
+ type: FieldType.number
61
+ },
62
+ {
63
+ id: 'complete', name: '% Complete', field: 'percentComplete',
64
+ formatter: Formatters.percentCompleteBar,
65
+ type: FieldType.number
66
+ },
67
+ {
68
+ id: 'start', name: 'Start', field: 'start',
69
+ formatter: Formatters.dateIso,
70
+ sortable: true,
71
+ type: FieldType.date
72
+ },
73
+ {
74
+ id: 'finish', name: 'Finish', field: 'finish',
75
+ formatter: Formatters.dateIso, sortable: true,
76
+ type: FieldType.date
77
+ },
78
+ {
79
+ id: 'effort-driven', name: 'Effort Driven', field: 'effortDriven',
80
+ formatter: Formatters.checkmark,
81
+ type: FieldType.number
82
+ }
83
+ ];
84
+ this.selectedColumn = this.columnDefinitions[0];
85
+
86
+ this.gridOptions = {
87
+ // if you want to disable autoResize and use a fixed width which requires horizontal scrolling
88
+ // it's advised to disable the autoFitColumnsOnFirstLoad as well
89
+ // enableAutoResize: false,
90
+ // autoFitColumnsOnFirstLoad: false,
91
+
92
+ autoHeight: true,
93
+ autoResize: {
94
+ container: '#demo-container',
95
+ rightPadding: 10
96
+ },
97
+
98
+ // enable the filtering but hide the user filter row since we use our own single filter
99
+ enableFiltering: true,
100
+ showHeaderRow: false, // hide the filter row (header row)
101
+
102
+ enableGridMenu: false, // disable grid menu & remove vertical scroll
103
+ alwaysShowVerticalScroll: false,
104
+ enableColumnPicker: true,
105
+ enableCellNavigation: true,
106
+ enableRowSelection: true
107
+ };
108
+
109
+ // mock a dataset
110
+ const mockedDataset = [];
111
+ for (let i = 0; i < 25; i++) {
112
+ const randomYear = 2000 + Math.floor(Math.random() * 10);
113
+ const randomMonth = Math.floor(Math.random() * 11);
114
+ const randomDay = Math.floor((Math.random() * 29));
115
+ const randomPercent = Math.round(Math.random() * 100);
116
+
117
+ mockedDataset[i] = {
118
+ id: i,
119
+ title: 'Task ' + i,
120
+ duration: Math.round(Math.random() * 100) + '',
121
+ percentComplete: randomPercent,
122
+ percentCompleteNumber: randomPercent,
123
+ start: new Date(randomYear, randomMonth, randomDay),
124
+ finish: new Date(randomYear, (randomMonth + 1), randomDay),
125
+ effortDriven: (i % 5 === 0)
126
+ };
127
+ }
128
+ this.dataset = mockedDataset;
129
+ }
130
+
131
+ //
132
+ // -- if any of the Search form input changes, we'll call the updateFilter() method
133
+ //
134
+
135
+ cleargridSearchInput() {
136
+ this.searchValue = '';
137
+ this.updateFilter();
138
+ }
139
+
140
+ updateFilter() {
141
+ this.angularGrid.filterService.updateSingleFilter({
142
+ columnId: `${this.selectedColumn!.id || ''}`,
143
+ operator: this.selectedOperator as OperatorString,
144
+ searchTerms: [this.searchValue || '']
145
+ });
146
+ }
147
+ }
@@ -0,0 +1,29 @@
1
+ <div id="demo-container" class="container-fluid">
2
+ <h2>
3
+ {{title}}
4
+ <span class="float-end">
5
+ <a style="font-size: 18px"
6
+ target="_blank"
7
+ href="https://github.com/ghiscoding/Angular-Slickgrid/blob/master/src/app/examples/grid-basic.component.ts">
8
+ <span class="fa fa-link"></span> code
9
+ </a>
10
+ </span>
11
+ </h2>
12
+ <div class="subtitle" [innerHTML]="subTitle"></div>
13
+
14
+ <h3>Grid 1</h3>
15
+ <angular-slickgrid gridId="grid1"
16
+ [columnDefinitions]="columnDefinitions1"
17
+ [gridOptions]="gridOptions1"
18
+ [dataset]="dataset1">
19
+ </angular-slickgrid>
20
+
21
+ <hr />
22
+
23
+ <h3>Grid 2 <small>(with local Pagination)</small></h3>
24
+ <angular-slickgrid gridId="grid2"
25
+ [columnDefinitions]="columnDefinitions2"
26
+ [gridOptions]="gridOptions2"
27
+ [dataset]="dataset2">
28
+ </angular-slickgrid>
29
+ </div>
@@ -0,0 +1,82 @@
1
+ import { Component, OnInit } from '@angular/core';
2
+ import { Column, GridOption, Formatters } from './../modules/angular-slickgrid';
3
+
4
+ const NB_ITEMS = 995;
5
+
6
+ @Component({
7
+ templateUrl: './grid-basic.component.html'
8
+ })
9
+ export class GridBasicComponent implements OnInit {
10
+ title = 'Example 1: Basic Grids';
11
+ subTitle = `
12
+ Basic Grids with fixed sizes (800 x 225) set by "gridHeight" &amp; "gridWidth"
13
+ <ul>
14
+ <li><a href="https://github.com/ghiscoding/Angular-Slickgrid/wiki/HOWTO---Step-by-Step" target="_blank">Wiki HOWTO link</a></li>
15
+ </ul>
16
+ `;
17
+
18
+ columnDefinitions1: Column[] = [];
19
+ columnDefinitions2: Column[] = [];
20
+ gridOptions1!: GridOption;
21
+ gridOptions2!: GridOption;
22
+ dataset1!: any[];
23
+ dataset2!: any[];
24
+
25
+ ngOnInit(): void {
26
+ this.columnDefinitions1 = [
27
+ { id: 'title', name: 'Title', field: 'title', sortable: true },
28
+ { id: 'duration', name: 'Duration (days)', field: 'duration', sortable: true },
29
+ { id: '%', name: '% Complete', field: 'percentComplete', sortable: true },
30
+ { id: 'start', name: 'Start', field: 'start', formatter: Formatters.dateIso },
31
+ { id: 'finish', name: 'Finish', field: 'finish', formatter: Formatters.dateIso },
32
+ { id: 'effort-driven', name: 'Effort Driven', field: 'effortDriven', sortable: true }
33
+ ];
34
+ this.gridOptions1 = {
35
+ enableAutoResize: false,
36
+ enableSorting: true,
37
+ gridHeight: 225,
38
+ gridWidth: 800,
39
+ };
40
+
41
+ // copy the same Grid Options and Column Definitions to 2nd grid
42
+ // but also add Pagination in this grid
43
+ this.columnDefinitions2 = this.columnDefinitions1;
44
+ this.gridOptions2 = {
45
+ ...this.gridOptions1,
46
+ ...{
47
+ enablePagination: true,
48
+ pagination: {
49
+ pageSizes: [5, 10, 20, 25, 50],
50
+ pageSize: 5
51
+ },
52
+ }
53
+ };
54
+
55
+ // mock some data (different in each dataset)
56
+ this.dataset1 = this.mockData(NB_ITEMS);
57
+ this.dataset2 = this.mockData(NB_ITEMS);
58
+ }
59
+
60
+ mockData(count: number) {
61
+ // mock a dataset
62
+ const mockDataset = [];
63
+ for (let i = 0; i < count; i++) {
64
+ const randomYear = 2000 + Math.floor(Math.random() * 10);
65
+ const randomMonth = Math.floor(Math.random() * 11);
66
+ const randomDay = Math.floor((Math.random() * 29));
67
+ const randomPercent = Math.round(Math.random() * 100);
68
+
69
+ mockDataset[i] = {
70
+ id: i,
71
+ title: 'Task ' + i,
72
+ duration: Math.round(Math.random() * 100) + '',
73
+ percentComplete: randomPercent,
74
+ start: new Date(randomYear, randomMonth + 1, randomDay),
75
+ finish: new Date(randomYear + 1, randomMonth + 1, randomDay),
76
+ effortDriven: (i % 5 === 0)
77
+ };
78
+ }
79
+
80
+ return mockDataset;
81
+ }
82
+ }