angular-slickgrid 4.1.2 → 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.
- package/.browserslistrc +12 -0
- package/.codecov.yml +17 -0
- package/.editorconfig +18 -0
- package/.eslintrc.json +50 -0
- package/.github/CODE_OF_CONDUCT.md +76 -0
- package/.github/FUNDING.yml +8 -0
- package/.github/ISSUE_TEMPLATE/bug_report.yml +54 -0
- package/.github/ISSUE_TEMPLATE/config.yml +5 -0
- package/.github/ISSUE_TEMPLATE/feature_request.yml +44 -0
- package/.github/renovate.json5 +26 -0
- package/.github/stale.yml +7 -0
- package/.github/workflows/main.yml +83 -0
- package/.vscode/extensions.json +9 -0
- package/.vscode/launch.json +72 -0
- package/.vscode/settings.json +7 -0
- package/.vscode/tasks.json +77 -0
- package/CHANGELOG.md +1172 -0
- package/LICENSE +20 -20
- package/README.md +9 -7
- package/angular.json +148 -0
- package/dist/LICENSE +20 -0
- package/dist/README.md +182 -0
- package/{angular-slickgrid.d.ts → dist/angular-slickgrid.d.ts} +0 -0
- package/{app → dist/app}/modules/angular-slickgrid/components/angular-slickgrid.component.d.ts +0 -0
- package/{app → dist/app}/modules/angular-slickgrid/constants.d.ts +0 -0
- package/{app → dist/app}/modules/angular-slickgrid/extensions/index.d.ts +0 -0
- package/{app → dist/app}/modules/angular-slickgrid/extensions/slickRowDetailView.d.ts +0 -0
- package/{app → dist/app}/modules/angular-slickgrid/global-grid-options.d.ts +0 -0
- package/{app → dist/app}/modules/angular-slickgrid/index.d.ts +0 -0
- package/{app → dist/app}/modules/angular-slickgrid/models/angularComponentOutput.interface.d.ts +0 -0
- package/{app → dist/app}/modules/angular-slickgrid/models/angularGridInstance.interface.d.ts +0 -0
- package/{app → dist/app}/modules/angular-slickgrid/models/externalTestingDependencies.interface.d.ts +0 -0
- package/{app → dist/app}/modules/angular-slickgrid/models/gridOption.interface.d.ts +0 -0
- package/{app → dist/app}/modules/angular-slickgrid/models/index.d.ts +0 -0
- package/{app → dist/app}/modules/angular-slickgrid/models/rowDetailView.interface.d.ts +0 -0
- package/{app → dist/app}/modules/angular-slickgrid/models/slickGrid.interface.d.ts +0 -0
- package/{app → dist/app}/modules/angular-slickgrid/modules/angular-slickgrid.module.d.ts +0 -0
- package/{app → dist/app}/modules/angular-slickgrid/services/angularUtil.service.d.ts +0 -0
- package/{app → dist/app}/modules/angular-slickgrid/services/bsDropdown.service.d.ts +0 -0
- package/{app → dist/app}/modules/angular-slickgrid/services/container.service.d.ts +0 -0
- package/{app → dist/app}/modules/angular-slickgrid/services/index.d.ts +0 -0
- package/{app → dist/app}/modules/angular-slickgrid/services/translater.service.d.ts +0 -0
- package/{app → dist/app}/modules/angular-slickgrid/services/utilities.d.ts +0 -0
- package/{app → dist/app}/modules/angular-slickgrid/slickgrid-config.d.ts +0 -0
- package/{esm2020 → dist/esm2020}/angular-slickgrid.mjs +0 -0
- package/dist/esm2020/app/modules/angular-slickgrid/components/angular-slickgrid.component.mjs +1171 -0
- package/{esm2020 → dist/esm2020}/app/modules/angular-slickgrid/constants.mjs +1 -1
- package/{esm2020 → dist/esm2020}/app/modules/angular-slickgrid/extensions/index.mjs +1 -1
- package/{esm2020 → dist/esm2020}/app/modules/angular-slickgrid/extensions/slickRowDetailView.mjs +2 -2
- package/{esm2020 → dist/esm2020}/app/modules/angular-slickgrid/global-grid-options.mjs +1 -1
- package/{esm2020 → dist/esm2020}/app/modules/angular-slickgrid/index.mjs +1 -1
- package/{esm2020 → dist/esm2020}/app/modules/angular-slickgrid/models/angularComponentOutput.interface.mjs +1 -1
- package/dist/esm2020/app/modules/angular-slickgrid/models/angularGridInstance.interface.mjs +2 -0
- package/dist/esm2020/app/modules/angular-slickgrid/models/externalTestingDependencies.interface.mjs +2 -0
- package/dist/esm2020/app/modules/angular-slickgrid/models/gridOption.interface.mjs +2 -0
- package/{esm2020 → dist/esm2020}/app/modules/angular-slickgrid/models/index.mjs +1 -1
- package/dist/esm2020/app/modules/angular-slickgrid/models/rowDetailView.interface.mjs +2 -0
- package/dist/esm2020/app/modules/angular-slickgrid/models/slickGrid.interface.mjs +2 -0
- package/{esm2020 → dist/esm2020}/app/modules/angular-slickgrid/modules/angular-slickgrid.module.mjs +5 -5
- package/{esm2020 → dist/esm2020}/app/modules/angular-slickgrid/services/angularUtil.service.mjs +4 -4
- package/{esm2020 → dist/esm2020}/app/modules/angular-slickgrid/services/bsDropdown.service.mjs +4 -4
- package/{esm2020 → dist/esm2020}/app/modules/angular-slickgrid/services/container.service.mjs +4 -4
- package/{esm2020 → dist/esm2020}/app/modules/angular-slickgrid/services/index.mjs +1 -1
- package/{esm2020 → dist/esm2020}/app/modules/angular-slickgrid/services/translater.service.mjs +4 -4
- package/{esm2020 → dist/esm2020}/app/modules/angular-slickgrid/services/utilities.mjs +1 -1
- package/{esm2020 → dist/esm2020}/app/modules/angular-slickgrid/slickgrid-config.mjs +1 -1
- package/{esm2020 → dist/esm2020}/public_api.mjs +1 -1
- package/{fesm2015 → dist/fesm2015}/angular-slickgrid.mjs +25 -22
- package/dist/fesm2015/angular-slickgrid.mjs.map +1 -0
- package/{fesm2020 → dist/fesm2020}/angular-slickgrid.mjs +25 -22
- package/dist/fesm2020/angular-slickgrid.mjs.map +1 -0
- package/{i18n → dist/i18n}/en.json +89 -89
- package/{i18n → dist/i18n}/fr.json +90 -90
- package/dist/package.json +79 -0
- package/{public_api.d.ts → dist/public_api.d.ts} +0 -0
- package/global.d.ts +1 -0
- package/ngcc.config.js +13 -0
- package/package.json +124 -37
- package/screenshots/column-picker.png +0 -0
- package/screenshots/composite-editor.png +0 -0
- package/screenshots/draggable-grouping.png +0 -0
- package/screenshots/editors.png +0 -0
- package/screenshots/export-to-file.png +0 -0
- package/screenshots/filter_and_sort.png +0 -0
- package/screenshots/formatters.png +0 -0
- package/screenshots/frozen.png +0 -0
- package/screenshots/multipleSelectFilter.png +0 -0
- package/screenshots/pagination.png +0 -0
- package/screenshots/selectFilter.png +0 -0
- package/screenshots/singleFilter.png +0 -0
- package/src/app/app-routing.module.ts +83 -0
- package/src/app/app.component.html +160 -0
- package/src/app/app.component.scss +65 -0
- package/src/app/app.component.ts +10 -0
- package/src/app/app.module.ts +175 -0
- package/src/app/examples/custom-angularComponentEditor.ts +184 -0
- package/src/app/examples/custom-angularComponentFilter.ts +126 -0
- package/src/app/examples/custom-inputEditor.ts +124 -0
- package/src/app/examples/custom-inputFilter.ts +142 -0
- package/src/app/examples/custom-titleFormatter.component.ts +8 -0
- package/src/app/examples/editor-ng-select.component.ts +37 -0
- package/src/app/examples/filter-ng-select.component.ts +32 -0
- package/src/app/examples/grid-additem.component.html +48 -0
- package/src/app/examples/grid-additem.component.ts +272 -0
- package/src/app/examples/grid-angular.component.html +79 -0
- package/src/app/examples/grid-angular.component.scss +28 -0
- package/src/app/examples/grid-angular.component.ts +370 -0
- package/src/app/examples/grid-autoheight.component.html +52 -0
- package/src/app/examples/grid-autoheight.component.ts +147 -0
- package/src/app/examples/grid-basic.component.html +29 -0
- package/src/app/examples/grid-basic.component.ts +82 -0
- package/src/app/examples/grid-clientside.component.html +51 -0
- package/src/app/examples/grid-clientside.component.ts +293 -0
- package/src/app/examples/grid-colspan.component.html +39 -0
- package/src/app/examples/grid-colspan.component.scss +11 -0
- package/src/app/examples/grid-colspan.component.ts +155 -0
- package/src/app/examples/grid-composite-editor.component.html +79 -0
- package/src/app/examples/grid-composite-editor.component.scss +19 -0
- package/src/app/examples/grid-composite-editor.component.ts +948 -0
- package/src/app/examples/grid-contextmenu.component.html +62 -0
- package/src/app/examples/grid-contextmenu.component.scss +44 -0
- package/src/app/examples/grid-contextmenu.component.ts +473 -0
- package/src/app/examples/grid-custom-tooltip.component.html +25 -0
- package/src/app/examples/grid-custom-tooltip.component.scss +77 -0
- package/src/app/examples/grid-custom-tooltip.component.ts +483 -0
- package/src/app/examples/grid-draggrouping.component.html +93 -0
- package/src/app/examples/grid-draggrouping.component.ts +397 -0
- package/src/app/examples/grid-editor.component.html +88 -0
- package/src/app/examples/grid-editor.component.ts +699 -0
- package/src/app/examples/grid-formatter.component.html +26 -0
- package/src/app/examples/grid-formatter.component.ts +162 -0
- package/src/app/examples/grid-frozen.component.html +65 -0
- package/src/app/examples/grid-frozen.component.scss +11 -0
- package/src/app/examples/grid-frozen.component.ts +303 -0
- package/src/app/examples/grid-graphql-nopage.component.html +33 -0
- package/src/app/examples/grid-graphql-nopage.component.scss +9 -0
- package/src/app/examples/grid-graphql-nopage.component.ts +242 -0
- package/src/app/examples/grid-graphql.component.html +87 -0
- package/src/app/examples/grid-graphql.component.ts +304 -0
- package/src/app/examples/grid-grouping.component.html +80 -0
- package/src/app/examples/grid-grouping.component.ts +313 -0
- package/src/app/examples/grid-headerbutton.component.html +31 -0
- package/src/app/examples/grid-headerbutton.component.scss +10 -0
- package/src/app/examples/grid-headerbutton.component.ts +233 -0
- package/src/app/examples/grid-headermenu.component.html +31 -0
- package/src/app/examples/grid-headermenu.component.scss +25 -0
- package/src/app/examples/grid-headermenu.component.ts +159 -0
- package/src/app/examples/grid-localization.component.html +54 -0
- package/src/app/examples/grid-localization.component.ts +293 -0
- package/src/app/examples/grid-menu.component.html +37 -0
- package/src/app/examples/grid-menu.component.scss +28 -0
- package/src/app/examples/grid-menu.component.ts +229 -0
- package/src/app/examples/grid-odata.component.html +116 -0
- package/src/app/examples/grid-odata.component.ts +441 -0
- package/src/app/examples/grid-range.component.html +74 -0
- package/src/app/examples/grid-range.component.ts +291 -0
- package/src/app/examples/grid-remote.component.html +37 -0
- package/src/app/examples/grid-remote.component.ts +153 -0
- package/src/app/examples/grid-resize-by-content.component.html +62 -0
- package/src/app/examples/grid-resize-by-content.component.scss +19 -0
- package/src/app/examples/grid-resize-by-content.component.ts +780 -0
- package/src/app/examples/grid-rowdetail.component.html +35 -0
- package/src/app/examples/grid-rowdetail.component.ts +205 -0
- package/src/app/examples/grid-rowmove.component.html +49 -0
- package/src/app/examples/grid-rowmove.component.ts +234 -0
- package/src/app/examples/grid-rowselection.component.html +76 -0
- package/src/app/examples/grid-rowselection.component.ts +267 -0
- package/src/app/examples/grid-state.component.html +36 -0
- package/src/app/examples/grid-state.component.ts +259 -0
- package/src/app/examples/grid-tabs.component.html +35 -0
- package/src/app/examples/grid-tabs.component.ts +115 -0
- package/src/app/examples/grid-trading.component.html +58 -0
- package/src/app/examples/grid-trading.component.scss +49 -0
- package/src/app/examples/grid-trading.component.ts +319 -0
- package/src/app/examples/grid-tree-data-hierarchical.component.html +79 -0
- package/src/app/examples/grid-tree-data-hierarchical.component.scss +47 -0
- package/src/app/examples/grid-tree-data-hierarchical.component.ts +311 -0
- package/src/app/examples/grid-tree-data-parent-child.component.html +108 -0
- package/src/app/examples/grid-tree-data-parent-child.component.scss +10 -0
- package/src/app/examples/grid-tree-data-parent-child.component.ts +351 -0
- package/src/app/examples/home.component.html +41 -0
- package/src/app/examples/home.component.ts +9 -0
- package/src/app/examples/rowdetail-preload.component.ts +10 -0
- package/src/app/examples/rowdetail-view.component.html +36 -0
- package/src/app/examples/rowdetail-view.component.ts +54 -0
- package/src/app/examples/swt-common-grid-pagination.component.ts +156 -0
- package/src/app/examples/swt-common-grid-test.component.html +30 -0
- package/src/app/examples/swt-common-grid-test.component.ts +219 -0
- package/src/app/examples/swt-common-grid.component.ts +436 -0
- package/src/app/examples/swt-logger.service.ts +165 -0
- package/src/app/modules/angular-slickgrid/components/angular-slickgrid.component.html +4 -0
- package/src/app/modules/angular-slickgrid/components/angular-slickgrid.component.ts +1395 -0
- package/src/app/modules/angular-slickgrid/constants.ts +97 -0
- package/src/app/modules/angular-slickgrid/extensions/index.ts +1 -0
- package/src/app/modules/angular-slickgrid/extensions/slickRowDetailView.ts +375 -0
- package/src/app/modules/angular-slickgrid/global-grid-options.ts +245 -0
- package/src/app/modules/angular-slickgrid/index.ts +11 -0
- package/src/app/modules/angular-slickgrid/models/angularComponentOutput.interface.ts +6 -0
- package/src/app/modules/angular-slickgrid/models/angularGridInstance.interface.ts +68 -0
- package/src/app/modules/angular-slickgrid/models/externalTestingDependencies.interface.ts +37 -0
- package/src/app/modules/angular-slickgrid/models/gridOption.interface.ts +12 -0
- package/src/app/modules/angular-slickgrid/models/index.ts +6 -0
- package/src/app/modules/angular-slickgrid/models/rowDetailView.interface.ts +33 -0
- package/src/app/modules/angular-slickgrid/models/slickGrid.interface.ts +7 -0
- package/src/app/modules/angular-slickgrid/modules/angular-slickgrid.module.ts +37 -0
- package/src/app/modules/angular-slickgrid/services/angularUtil.service.ts +48 -0
- package/src/app/modules/angular-slickgrid/services/bsDropdown.service.ts +142 -0
- package/src/app/modules/angular-slickgrid/services/container.service.ts +24 -0
- package/src/app/modules/angular-slickgrid/services/index.ts +5 -0
- package/src/app/modules/angular-slickgrid/services/translater.service.ts +38 -0
- package/src/app/modules/angular-slickgrid/services/utilities.ts +19 -0
- package/src/app/modules/angular-slickgrid/slickgrid-config.ts +10 -0
- package/src/app/slickgrid-custom-variables.scss +10 -0
- package/src/assets/.gitkeep +0 -0
- package/src/assets/data/collection_100_numbers.json +12 -0
- package/src/assets/data/collection_500_numbers.json +52 -0
- package/src/assets/data/countries.json +245 -0
- package/src/assets/data/country_names.json +245 -0
- package/src/assets/data/customers_100.json +102 -0
- package/src/assets/i18n/en.json +90 -0
- package/src/assets/i18n/fr.json +91 -0
- package/src/environments/environment.prod.ts +3 -0
- package/src/environments/environment.ts +8 -0
- package/src/favicon.ico +0 -0
- package/src/index.html +18 -0
- package/src/main.ts +13 -0
- package/src/polyfills.ts +52 -0
- package/src/public_api.ts +1 -0
- package/src/styles.scss +66 -0
- package/src/typings.d.ts +10 -0
- package/tsconfig.app.json +25 -0
- package/tsconfig.json +40 -0
- package/tsconfig.spec.json +23 -0
- package/docs/assets/lib/multiple-select/README.md +0 -17
- package/esm2020/app/modules/angular-slickgrid/components/angular-slickgrid.component.mjs +0 -1168
- package/esm2020/app/modules/angular-slickgrid/models/angularGridInstance.interface.mjs +0 -2
- package/esm2020/app/modules/angular-slickgrid/models/externalTestingDependencies.interface.mjs +0 -2
- package/esm2020/app/modules/angular-slickgrid/models/gridOption.interface.mjs +0 -2
- package/esm2020/app/modules/angular-slickgrid/models/rowDetailView.interface.mjs +0 -2
- package/esm2020/app/modules/angular-slickgrid/models/slickGrid.interface.mjs +0 -2
- package/fesm2015/angular-slickgrid.mjs.map +0 -1
- package/fesm2020/angular-slickgrid.mjs.map +0 -1
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
import { Component, OnInit, ViewEncapsulation } from '@angular/core';
|
|
2
|
+
import { AngularGridInstance, Column, Editors, FieldType, Formatters, GridOption, GridService, OnEventArgs, SlickDataView, SlickGrid } from './../modules/angular-slickgrid';
|
|
3
|
+
|
|
4
|
+
@Component({
|
|
5
|
+
styles: ['.duration-bg { background-color: #e9d4f1 !important }'],
|
|
6
|
+
encapsulation: ViewEncapsulation.None,
|
|
7
|
+
templateUrl: './grid-additem.component.html'
|
|
8
|
+
})
|
|
9
|
+
export class GridAddItemComponent implements OnInit {
|
|
10
|
+
title = 'Example 11: Add / Update / Highlight a Datagrid Item';
|
|
11
|
+
subTitle = `
|
|
12
|
+
Add / Update / Hightlight an Item from the Datagrid (<a href="https://github.com/ghiscoding/Angular-Slickgrid/wiki/Add,-Update-or-Highlight-a-Datagrid-Item" target="_blank">Wiki docs</a>).
|
|
13
|
+
<ul>
|
|
14
|
+
<li><b>Note:</b> this demo is <b>only</b> on the datagrid (client) side, you still need to deal with the backend yourself</li>
|
|
15
|
+
<li>Adding an item, will always be showing as the 1st item in the grid because that is the best visual place to add it</li>
|
|
16
|
+
<li>Add/Update an item requires a valid Slickgrid Selection Model, you have 2 choices to deal with this:</li>
|
|
17
|
+
<ul><li>You can enable "enableCheckboxSelector" or "enableRowSelection" to True</li></ul>
|
|
18
|
+
<li>Click on any of the buttons below to test this out</li>
|
|
19
|
+
<li>You can change the highlighted color & animation by changing the <a href="https://github.com/ghiscoding/Angular-Slickgrid/blob/master/src/app/modules/angular-slickgrid/styles/_variables.scss" target="_blank">SASS Variables</a>:</li>
|
|
20
|
+
<ul>
|
|
21
|
+
<li>"$row-highlight-background-color" or "$row-highlight-fade-animation"</li>
|
|
22
|
+
</ul>
|
|
23
|
+
<li>You can also add CSS class(es) on the fly (or on page load) on rows with certain criteria, (e.g. click on last button)
|
|
24
|
+
<ul>
|
|
25
|
+
<li>Example, click on button "Highlight Rows with Duration over 50" to see row styling changing. <a href="https://github.com/ghiscoding/Angular-Slickgrid/wiki/Dynamically-Add-CSS-Classes-to-Item-Rows" target="_blank">Wiki doc</a></li>
|
|
26
|
+
</ul>
|
|
27
|
+
</ul>
|
|
28
|
+
`;
|
|
29
|
+
|
|
30
|
+
angularGrid!: AngularGridInstance;
|
|
31
|
+
grid!: SlickGrid;
|
|
32
|
+
gridService!: GridService;
|
|
33
|
+
dataView!: SlickDataView;
|
|
34
|
+
columnDefinitions: Column[] = [];
|
|
35
|
+
gridOptions!: GridOption;
|
|
36
|
+
dataset: any[];
|
|
37
|
+
updatedObject: any;
|
|
38
|
+
|
|
39
|
+
constructor() {
|
|
40
|
+
// mock a dataset
|
|
41
|
+
this.dataset = this.mockDataset(1000);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
angularGridReady(angularGrid: AngularGridInstance) {
|
|
45
|
+
this.angularGrid = angularGrid;
|
|
46
|
+
this.dataView = angularGrid.dataView;
|
|
47
|
+
this.grid = angularGrid.slickGrid as SlickGrid;
|
|
48
|
+
this.gridService = angularGrid.gridService;
|
|
49
|
+
|
|
50
|
+
// if you want to change background color of Duration over 50 right after page load,
|
|
51
|
+
// you would put the code here, also make sure to re-render the grid for the styling to be applied right away
|
|
52
|
+
/*
|
|
53
|
+
this.dataView.getItemMetadata = this.updateItemMetadataForDurationOver50(this.dataView.getItemMetadata);
|
|
54
|
+
this.grid.invalidate();
|
|
55
|
+
this.grid.render();
|
|
56
|
+
*/
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
ngOnInit(): void {
|
|
60
|
+
this.columnDefinitions = [
|
|
61
|
+
{
|
|
62
|
+
id: 'delete',
|
|
63
|
+
field: 'id',
|
|
64
|
+
excludeFromHeaderMenu: true,
|
|
65
|
+
formatter: Formatters.deleteIcon,
|
|
66
|
+
minWidth: 30,
|
|
67
|
+
maxWidth: 30,
|
|
68
|
+
// use onCellClick OR grid.onClick.subscribe which you can see down below
|
|
69
|
+
onCellClick: (e: Event, args: OnEventArgs) => {
|
|
70
|
+
console.log(args);
|
|
71
|
+
if (confirm('Are you sure?')) {
|
|
72
|
+
this.angularGrid.gridService.deleteItemById(args.dataContext.id);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
id: 'title', name: 'Title', field: 'title',
|
|
78
|
+
sortable: true,
|
|
79
|
+
type: FieldType.string,
|
|
80
|
+
editor: {
|
|
81
|
+
model: Editors.longText
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
id: 'duration', name: 'Duration (days)', field: 'duration',
|
|
86
|
+
sortable: true,
|
|
87
|
+
type: FieldType.number,
|
|
88
|
+
editor: {
|
|
89
|
+
model: Editors.text
|
|
90
|
+
},
|
|
91
|
+
onCellChange: (e: Event, args: OnEventArgs) => {
|
|
92
|
+
alert('onCellChange directly attached to the column definition');
|
|
93
|
+
console.log(args);
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
id: 'complete', name: '% Complete', field: 'percentComplete',
|
|
98
|
+
formatter: Formatters.percentCompleteBar,
|
|
99
|
+
type: FieldType.number,
|
|
100
|
+
editor: {
|
|
101
|
+
model: Editors.integer
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
id: 'start', name: 'Start', field: 'start',
|
|
106
|
+
formatter: Formatters.dateIso,
|
|
107
|
+
sortable: true,
|
|
108
|
+
type: FieldType.date,
|
|
109
|
+
/*
|
|
110
|
+
editor: {
|
|
111
|
+
model: Editors.date
|
|
112
|
+
}
|
|
113
|
+
*/
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
id: 'finish', name: 'Finish', field: 'finish',
|
|
117
|
+
formatter: Formatters.dateIso, sortable: true,
|
|
118
|
+
type: FieldType.date
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
id: 'effort-driven', name: 'Effort Driven', field: 'effortDriven',
|
|
122
|
+
formatter: Formatters.checkmark,
|
|
123
|
+
type: FieldType.number,
|
|
124
|
+
editor: {
|
|
125
|
+
model: Editors.checkbox
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
];
|
|
129
|
+
|
|
130
|
+
this.gridOptions = {
|
|
131
|
+
asyncEditorLoading: false,
|
|
132
|
+
autoResize: {
|
|
133
|
+
container: '#demo-container',
|
|
134
|
+
rightPadding: 10
|
|
135
|
+
},
|
|
136
|
+
editable: true,
|
|
137
|
+
enableColumnPicker: true,
|
|
138
|
+
enableCellNavigation: true,
|
|
139
|
+
enableRowSelection: true
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
mockDataset(itemCount: number) {
|
|
144
|
+
// mock a dataset
|
|
145
|
+
const mockedDataset = [];
|
|
146
|
+
for (let i = 0; i < itemCount; i++) {
|
|
147
|
+
const randomYear = 2000 + Math.floor(Math.random() * 10);
|
|
148
|
+
const randomMonth = Math.floor(Math.random() * 11);
|
|
149
|
+
const randomDay = Math.floor((Math.random() * 29));
|
|
150
|
+
const randomPercent = Math.round(Math.random() * 100);
|
|
151
|
+
mockedDataset[i] = {
|
|
152
|
+
id: i,
|
|
153
|
+
title: 'Task ' + i,
|
|
154
|
+
duration: Math.round(Math.random() * 100) + '',
|
|
155
|
+
percentComplete: randomPercent,
|
|
156
|
+
percentCompleteNumber: randomPercent,
|
|
157
|
+
start: new Date(randomYear, randomMonth, randomDay),
|
|
158
|
+
finish: new Date(randomYear, (randomMonth + 1), randomDay),
|
|
159
|
+
effortDriven: (i % 5 === 0)
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
return mockedDataset;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
addNewItem(insertPosition?: 'top' | 'bottom') {
|
|
166
|
+
const newItem1 = this.createNewItem(1);
|
|
167
|
+
const newItem2 = this.createNewItem(2);
|
|
168
|
+
|
|
169
|
+
// single insert
|
|
170
|
+
this.angularGrid.gridService.addItem(newItem1, { position: insertPosition });
|
|
171
|
+
|
|
172
|
+
// OR multiple inserts
|
|
173
|
+
// this.angularGrid.gridService.addItems([newItem1, newItem2], { position: insertPosition });
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
createNewItem(incrementIdByHowMany = 1) {
|
|
177
|
+
const dataset = this.angularGrid.dataView.getItems();
|
|
178
|
+
let highestId = 0;
|
|
179
|
+
dataset.forEach((item: any) => {
|
|
180
|
+
if (item.id > highestId) {
|
|
181
|
+
highestId = item.id;
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
const newId = highestId + incrementIdByHowMany;
|
|
185
|
+
const randomYear = 2000 + Math.floor(Math.random() * 10);
|
|
186
|
+
const randomMonth = Math.floor(Math.random() * 11);
|
|
187
|
+
const randomDay = Math.floor((Math.random() * 29));
|
|
188
|
+
const randomPercent = Math.round(Math.random() * 100);
|
|
189
|
+
|
|
190
|
+
return {
|
|
191
|
+
id: newId,
|
|
192
|
+
title: 'Task ' + newId,
|
|
193
|
+
duration: Math.round(Math.random() * 100) + '',
|
|
194
|
+
percentComplete: randomPercent,
|
|
195
|
+
percentCompleteNumber: randomPercent,
|
|
196
|
+
start: new Date(randomYear, randomMonth, randomDay),
|
|
197
|
+
finish: new Date(randomYear, (randomMonth + 2), randomDay),
|
|
198
|
+
effortDriven: true
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
highlighFifthRow() {
|
|
203
|
+
this.scrollGridTop();
|
|
204
|
+
this.angularGrid.gridService.highlightRow(4, 1500);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/** Change the Duration Rows Background Color */
|
|
208
|
+
changeDurationBackgroundColor() {
|
|
209
|
+
this.dataView.getItemMetadata = this.updateItemMetadataForDurationOver40(this.dataView.getItemMetadata);
|
|
210
|
+
|
|
211
|
+
// also re-render the grid for the styling to be applied right away
|
|
212
|
+
this.grid.invalidate();
|
|
213
|
+
this.grid.render();
|
|
214
|
+
|
|
215
|
+
// or use the Angular-SlickGrid GridService
|
|
216
|
+
// this.gridService.renderGrid();
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Change the SlickGrid Item Metadata, we will add a CSS class on all rows with a Duration over 50
|
|
221
|
+
* For more info, you can see this SO https://stackoverflow.com/a/19985148/1212166
|
|
222
|
+
*/
|
|
223
|
+
updateItemMetadataForDurationOver40(previousItemMetadata: any) {
|
|
224
|
+
const newCssClass = 'duration-bg';
|
|
225
|
+
|
|
226
|
+
return (rowNumber: number) => {
|
|
227
|
+
const item = this.dataView.getItem(rowNumber);
|
|
228
|
+
let meta = {
|
|
229
|
+
cssClasses: ''
|
|
230
|
+
};
|
|
231
|
+
if (typeof previousItemMetadata === 'object') {
|
|
232
|
+
meta = previousItemMetadata(rowNumber);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
if (meta && item && item.duration) {
|
|
236
|
+
const duration = +item.duration; // convert to number
|
|
237
|
+
if (duration > 40) {
|
|
238
|
+
meta.cssClasses = (meta.cssClasses || '') + ' ' + newCssClass;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
return meta;
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
updateSecondItem() {
|
|
247
|
+
this.scrollGridTop();
|
|
248
|
+
const updatedItem = this.angularGrid.gridService.getDataItemByRowNumber(1);
|
|
249
|
+
updatedItem.duration = Math.round(Math.random() * 100);
|
|
250
|
+
this.angularGrid.gridService.updateItem(updatedItem);
|
|
251
|
+
|
|
252
|
+
// OR by id
|
|
253
|
+
// this.angularGrid.gridService.updateItemById(updatedItem.id, updatedItem);
|
|
254
|
+
|
|
255
|
+
// OR multiple changes
|
|
256
|
+
/*
|
|
257
|
+
const updatedItem1 = this.angularGrid.gridService.getDataItemByRowNumber(1);
|
|
258
|
+
const updatedItem2 = this.angularGrid.gridService.getDataItemByRowNumber(2);
|
|
259
|
+
updatedItem1.duration = Math.round(Math.random() * 100);
|
|
260
|
+
updatedItem2.duration = Math.round(Math.random() * 100);
|
|
261
|
+
this.angularGrid.gridService.updateItems([updatedItem1, updatedItem2], { highlightRow: true });
|
|
262
|
+
*/
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
scrollGridBottom() {
|
|
266
|
+
this.angularGrid.slickGrid.navigateBottom();
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
scrollGridTop() {
|
|
270
|
+
this.angularGrid.slickGrid.navigateTop();
|
|
271
|
+
}
|
|
272
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
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-angular.component.ts">
|
|
8
|
+
<span class="fa fa-link"></span> code
|
|
9
|
+
</a>
|
|
10
|
+
</span>
|
|
11
|
+
</h2>
|
|
12
|
+
<div class="subtitle"
|
|
13
|
+
[innerHTML]="subTitle"></div>
|
|
14
|
+
|
|
15
|
+
<div class="col-sm-6">
|
|
16
|
+
<label>autoEdit setting: </label>
|
|
17
|
+
<span id="radioAutoEdit">
|
|
18
|
+
<label class="radio-inline control-label"
|
|
19
|
+
for="radioTrue">
|
|
20
|
+
<input type="radio"
|
|
21
|
+
name="inlineRadioOptions"
|
|
22
|
+
id="radioTrue"
|
|
23
|
+
checked
|
|
24
|
+
[value]="isAutoEdit"
|
|
25
|
+
(change)="setAutoEdit(true)"> ON (single-click)
|
|
26
|
+
</label>
|
|
27
|
+
<label class="radio-inline control-label"
|
|
28
|
+
for="radioFalse">
|
|
29
|
+
<input type="radio"
|
|
30
|
+
name="inlineRadioOptions"
|
|
31
|
+
id="radioFalse"
|
|
32
|
+
[value]="isAutoEdit"
|
|
33
|
+
(change)="setAutoEdit(false)"> OFF (double-click)
|
|
34
|
+
</label>
|
|
35
|
+
</span>
|
|
36
|
+
<div class="row col-sm-12">
|
|
37
|
+
<span>
|
|
38
|
+
<button class="btn btn-outline-secondary btn-sm" (click)="undo()">
|
|
39
|
+
<i class="fa fa-undo"></i>
|
|
40
|
+
Undo last edit(s)
|
|
41
|
+
</button>
|
|
42
|
+
<button class="btn btn-outline-secondary btn-sm" (click)="angularGrid.filterService.clearFilters()">
|
|
43
|
+
Clear Filters
|
|
44
|
+
</button>
|
|
45
|
+
<button class="btn btn-outline-secondary btn-sm" (click)="angularGrid.sortService.clearSorting()">
|
|
46
|
+
Clear Sorting
|
|
47
|
+
</button>
|
|
48
|
+
<label class="checkbox-inline control-label" for="autoCommitEdit">
|
|
49
|
+
<input type="checkbox" id="autoCommitEdit" data-test="auto-commit"
|
|
50
|
+
[checked]="gridOptions.autoCommitEdit"
|
|
51
|
+
(click)="changeAutoCommit()">
|
|
52
|
+
Auto Commit Edit
|
|
53
|
+
</label>
|
|
54
|
+
</span>
|
|
55
|
+
</div>
|
|
56
|
+
</div>
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
<div class="col-sm-6">
|
|
60
|
+
<div class="alert alert-info" *ngIf="updatedObject">
|
|
61
|
+
<strong>Updated Item:</strong> {{updatedObject | json}}
|
|
62
|
+
</div>
|
|
63
|
+
<div class="alert alert-warning" *ngIf="alertWarning">
|
|
64
|
+
<strong>Updated Item:</strong> {{alertWarning}}
|
|
65
|
+
</div>
|
|
66
|
+
</div>
|
|
67
|
+
|
|
68
|
+
<div class="col-sm-12">
|
|
69
|
+
<angular-slickgrid gridId="grid22"
|
|
70
|
+
[columnDefinitions]="columnDefinitions"
|
|
71
|
+
[gridOptions]="gridOptions"
|
|
72
|
+
[dataset]="dataset"
|
|
73
|
+
(onAngularGridCreated)="angularGridReady($event.detail)"
|
|
74
|
+
(onCellChange)="onCellChanged($event.detail.eventData, $event.detail.args)"
|
|
75
|
+
(onClick)="onCellClicked($event.detail.eventData, $event.detail.args)"
|
|
76
|
+
(onValidationError)="onCellValidationError($event.detail.eventData, $event.detail.args)">
|
|
77
|
+
</angular-slickgrid>
|
|
78
|
+
</div>
|
|
79
|
+
</div>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
h3 {
|
|
2
|
+
font-style: normal;
|
|
3
|
+
color: #3d3d3d;
|
|
4
|
+
}
|
|
5
|
+
.fake-hyperlink {
|
|
6
|
+
color: #0d6efd;
|
|
7
|
+
text-decoration: underline;
|
|
8
|
+
text-decoration-color: #0d6efd;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
#slickGridContainer-grid22 {
|
|
12
|
+
.slickgrid-container {
|
|
13
|
+
.slick-headerrow-column {
|
|
14
|
+
.ng-input {
|
|
15
|
+
padding-top: -4px !important;
|
|
16
|
+
padding-left: 4px !important;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
.slick-cell {
|
|
20
|
+
line-height: 30px !important;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
input.slider-filter-input[type=range],
|
|
25
|
+
.form-control {
|
|
26
|
+
height: 34px !important;
|
|
27
|
+
}
|
|
28
|
+
}
|