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,80 @@
|
|
|
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-grouping.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="row">
|
|
16
|
+
<div class="col-sm-12">
|
|
17
|
+
<button class="btn btn-outline-secondary btn-xs" data-test="add-500-rows-btn" (click)="loadData(500)">
|
|
18
|
+
500 rows
|
|
19
|
+
</button>
|
|
20
|
+
<button class="btn btn-outline-secondary btn-xs" data-test="add-50k-rows-btn" (click)="loadData(50000)">
|
|
21
|
+
50k rows
|
|
22
|
+
</button>
|
|
23
|
+
<button class="btn btn-outline-secondary btn-xs" data-test="clear-grouping-btn" (click)="clearGrouping()">
|
|
24
|
+
<i class="fa fa-times"></i> Clear grouping
|
|
25
|
+
</button>
|
|
26
|
+
<button class="btn btn-outline-secondary btn-xs" data-test="collapse-all-btn" (click)="collapseAllGroups()">
|
|
27
|
+
<i class="fa fa-compress"></i> Collapse all groups
|
|
28
|
+
</button>
|
|
29
|
+
<button class="btn btn-outline-secondary btn-xs" data-test="expand-all-btn" (click)="expandAllGroups()">
|
|
30
|
+
<i class="fa fa-expand"></i> Expand all groups
|
|
31
|
+
</button>
|
|
32
|
+
<button class="btn btn-outline-secondary btn-xs" data-test="export-excel-btn" (click)="exportToExcel()">
|
|
33
|
+
<i class="fa fa-file-excel-o text-success"></i> Export to Excel
|
|
34
|
+
</button>
|
|
35
|
+
</div>
|
|
36
|
+
</div>
|
|
37
|
+
<hr />
|
|
38
|
+
<div class="row">
|
|
39
|
+
<div class="col-sm-12">
|
|
40
|
+
<button class="btn btn-outline-secondary btn-xs" data-test="group-duration-sort-value-btn"
|
|
41
|
+
(click)="groupByDuration()">
|
|
42
|
+
Group by duration & sort groups by value
|
|
43
|
+
</button>
|
|
44
|
+
<button class="btn btn-outline-secondary btn-xs" data-test="group-duration-sort-count-btn"
|
|
45
|
+
(click)="groupByDurationOrderByCount(false)">
|
|
46
|
+
Group by duration & sort groups by count
|
|
47
|
+
</button>
|
|
48
|
+
</div>
|
|
49
|
+
</div>
|
|
50
|
+
<div class="row">
|
|
51
|
+
<div class="col-sm-12">
|
|
52
|
+
<button class="btn btn-outline-secondary btn-xs" data-test="group-duration-sort-count-collapse-btn"
|
|
53
|
+
(click)="groupByDurationOrderByCount(true)">
|
|
54
|
+
Group by duration & sort groups by count, aggregate collapsed
|
|
55
|
+
</button>
|
|
56
|
+
<button class="btn btn-outline-secondary btn-xs" data-test="group-duration-effort-btn"
|
|
57
|
+
(click)="groupByDurationEffortDriven()">
|
|
58
|
+
Group by duration then effort-driven
|
|
59
|
+
</button>
|
|
60
|
+
<button class="btn btn-outline-secondary btn-xs" data-test="group-duration-effort-percent-btn"
|
|
61
|
+
(click)="groupByDurationEffortDrivenPercent()">
|
|
62
|
+
Group by duration then effort-driven then percent.
|
|
63
|
+
</button>
|
|
64
|
+
<span [hidden]="!processing">
|
|
65
|
+
<i class="fa fa-refresh fa-spin fa-lg fa-fw"></i>
|
|
66
|
+
</span>
|
|
67
|
+
</div>
|
|
68
|
+
</div>
|
|
69
|
+
|
|
70
|
+
<angular-slickgrid gridId="grid14"
|
|
71
|
+
[dataset]="dataset"
|
|
72
|
+
[columnDefinitions]="columnDefinitions"
|
|
73
|
+
[gridOptions]="gridOptions"
|
|
74
|
+
(onBeforeExportToTextFile)="processing = true"
|
|
75
|
+
(onAfterExportToTextFile)="processing = false"
|
|
76
|
+
(onBeforeExportToExcel)="processing = true"
|
|
77
|
+
(onAfterExportToExcel)="processing = false"
|
|
78
|
+
(onAngularGridCreated)="angularGridReady($event.detail)">
|
|
79
|
+
</angular-slickgrid>
|
|
80
|
+
</div>
|
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
import { Component, OnInit, } from '@angular/core';
|
|
2
|
+
import { ExcelExportService } from '@slickgrid-universal/excel-export';
|
|
3
|
+
import { TextExportService } from '@slickgrid-universal/text-export';
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
AngularGridInstance,
|
|
7
|
+
Aggregators,
|
|
8
|
+
Column,
|
|
9
|
+
DelimiterType,
|
|
10
|
+
FieldType,
|
|
11
|
+
FileType,
|
|
12
|
+
Filters,
|
|
13
|
+
Formatters,
|
|
14
|
+
GridOption,
|
|
15
|
+
Grouping,
|
|
16
|
+
GroupTotalFormatters,
|
|
17
|
+
SortDirectionNumber,
|
|
18
|
+
SortComparers,
|
|
19
|
+
} from './../modules/angular-slickgrid';
|
|
20
|
+
|
|
21
|
+
@Component({
|
|
22
|
+
templateUrl: './grid-grouping.component.html'
|
|
23
|
+
})
|
|
24
|
+
export class GridGroupingComponent implements OnInit {
|
|
25
|
+
title = 'Example 14: Grouping & Aggregators';
|
|
26
|
+
subTitle = `
|
|
27
|
+
(<a href="https://github.com/ghiscoding/Angular-Slickgrid/wiki/Grouping-&-Aggregators" target="_blank">Wiki docs</a>)
|
|
28
|
+
<ul>
|
|
29
|
+
<li>
|
|
30
|
+
Fully dynamic and interactive multi-level grouping with filtering and aggregates over 50'000 items
|
|
31
|
+
</li>
|
|
32
|
+
<li>Each grouping level can have its own aggregates (over child rows, child groups, or all descendant rows)..</li>
|
|
33
|
+
</ul>
|
|
34
|
+
`;
|
|
35
|
+
|
|
36
|
+
angularGrid!: AngularGridInstance;
|
|
37
|
+
columnDefinitions!: Column[];
|
|
38
|
+
gridOptions!: GridOption;
|
|
39
|
+
dataset!: any[];
|
|
40
|
+
gridObj: any;
|
|
41
|
+
dataviewObj: any;
|
|
42
|
+
processing = false;
|
|
43
|
+
excelExportService = new ExcelExportService();
|
|
44
|
+
textExportService = new TextExportService();
|
|
45
|
+
|
|
46
|
+
constructor() { }
|
|
47
|
+
|
|
48
|
+
ngOnInit(): void {
|
|
49
|
+
this.columnDefinitions = [
|
|
50
|
+
{
|
|
51
|
+
id: 'sel', name: '#', field: 'num', width: 40,
|
|
52
|
+
excludeFromExport: true,
|
|
53
|
+
maxWidth: 70,
|
|
54
|
+
resizable: true,
|
|
55
|
+
filterable: true,
|
|
56
|
+
selectable: false,
|
|
57
|
+
focusable: false
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
id: 'title', name: 'Title', field: 'title',
|
|
61
|
+
width: 50,
|
|
62
|
+
minWidth: 50,
|
|
63
|
+
cssClass: 'cell-title',
|
|
64
|
+
filterable: true,
|
|
65
|
+
sortable: true
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
id: 'duration', name: 'Duration', field: 'duration',
|
|
69
|
+
minWidth: 50, width: 60,
|
|
70
|
+
filterable: true,
|
|
71
|
+
filter: { model: Filters.slider, operator: '>=' },
|
|
72
|
+
sortable: true,
|
|
73
|
+
type: FieldType.number,
|
|
74
|
+
groupTotalsFormatter: GroupTotalFormatters.sumTotals,
|
|
75
|
+
params: { groupFormatterPrefix: 'Total: ' }
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
id: '%', name: '% Complete', field: 'percentComplete',
|
|
79
|
+
minWidth: 70, width: 90,
|
|
80
|
+
formatter: Formatters.percentCompleteBar,
|
|
81
|
+
filterable: true,
|
|
82
|
+
filter: { model: Filters.compoundSlider },
|
|
83
|
+
sortable: true,
|
|
84
|
+
type: FieldType.number,
|
|
85
|
+
groupTotalsFormatter: GroupTotalFormatters.avgTotalsPercentage,
|
|
86
|
+
params: { groupFormatterPrefix: '<i>Avg</i>: ' }
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
id: 'start', name: 'Start', field: 'start',
|
|
90
|
+
minWidth: 60,
|
|
91
|
+
filterable: true,
|
|
92
|
+
filter: { model: Filters.compoundDate },
|
|
93
|
+
sortable: true,
|
|
94
|
+
type: FieldType.dateIso,
|
|
95
|
+
formatter: Formatters.dateIso,
|
|
96
|
+
exportWithFormatter: true
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
id: 'finish', name: 'Finish', field: 'finish',
|
|
100
|
+
minWidth: 60,
|
|
101
|
+
filterable: true,
|
|
102
|
+
filter: { model: Filters.compoundDate },
|
|
103
|
+
sortable: true,
|
|
104
|
+
type: FieldType.dateIso,
|
|
105
|
+
formatter: Formatters.dateIso,
|
|
106
|
+
exportWithFormatter: true
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
id: 'cost', name: 'Cost', field: 'cost',
|
|
110
|
+
minWidth: 70,
|
|
111
|
+
width: 100,
|
|
112
|
+
filterable: true,
|
|
113
|
+
filter: { model: Filters.compoundInputNumber },
|
|
114
|
+
type: FieldType.number,
|
|
115
|
+
sortable: true,
|
|
116
|
+
exportWithFormatter: true,
|
|
117
|
+
formatter: Formatters.dollar,
|
|
118
|
+
groupTotalsFormatter: GroupTotalFormatters.sumTotalsDollar,
|
|
119
|
+
params: { groupFormatterPrefix: '<b>Total</b>: ' /*, groupFormatterSuffix: ' USD'*/ }
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
id: 'effort-driven', name: 'Effort Driven',
|
|
123
|
+
minWidth: 20, width: 80, maxWidth: 80,
|
|
124
|
+
cssClass: 'cell-effort-driven',
|
|
125
|
+
field: 'effortDriven',
|
|
126
|
+
formatter: Formatters.checkmark,
|
|
127
|
+
sortable: true,
|
|
128
|
+
filterable: true,
|
|
129
|
+
filter: {
|
|
130
|
+
collection: [{ value: '', label: '' }, { value: true, label: 'True' }, { value: false, label: 'False' }],
|
|
131
|
+
model: Filters.singleSelect,
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
];
|
|
135
|
+
|
|
136
|
+
this.gridOptions = {
|
|
137
|
+
autoResize: {
|
|
138
|
+
container: '#demo-container',
|
|
139
|
+
rightPadding: 10
|
|
140
|
+
},
|
|
141
|
+
enableExcelExport: true,
|
|
142
|
+
enableFiltering: true,
|
|
143
|
+
// you could debounce/throttle the input text filter if you have lots of data
|
|
144
|
+
// filterTypingDebounce: 250,
|
|
145
|
+
enableGrouping: true,
|
|
146
|
+
enableExport: true,
|
|
147
|
+
gridMenu: {
|
|
148
|
+
hideExportTextDelimitedCommand: false
|
|
149
|
+
},
|
|
150
|
+
excelExportOptions: { sanitizeDataExport: true },
|
|
151
|
+
textExportOptions: { sanitizeDataExport: true },
|
|
152
|
+
registerExternalResources: [this.excelExportService, this.textExportService],
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
this.loadData(500);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
angularGridReady(angularGrid: AngularGridInstance) {
|
|
159
|
+
this.angularGrid = angularGrid;
|
|
160
|
+
this.gridObj = angularGrid.slickGrid;
|
|
161
|
+
this.dataviewObj = angularGrid.dataView;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
loadData(rowCount: number) {
|
|
165
|
+
// mock a dataset
|
|
166
|
+
this.dataset = [];
|
|
167
|
+
for (let i = 0; i < rowCount; i++) {
|
|
168
|
+
const randomYear = 2000 + Math.floor(Math.random() * 10);
|
|
169
|
+
const randomMonth = Math.floor(Math.random() * 11);
|
|
170
|
+
const randomDay = Math.floor((Math.random() * 29));
|
|
171
|
+
const randomPercent = Math.round(Math.random() * 100);
|
|
172
|
+
|
|
173
|
+
this.dataset[i] = {
|
|
174
|
+
id: 'id_' + i,
|
|
175
|
+
num: i,
|
|
176
|
+
title: 'Task ' + i,
|
|
177
|
+
duration: Math.round(Math.random() * 100) + '',
|
|
178
|
+
percentComplete: randomPercent,
|
|
179
|
+
percentCompleteNumber: randomPercent,
|
|
180
|
+
start: new Date(randomYear, randomMonth, randomDay),
|
|
181
|
+
finish: new Date(randomYear, (randomMonth + 1), randomDay),
|
|
182
|
+
cost: (i % 33 === 0) ? null : Math.round(Math.random() * 10000) / 100,
|
|
183
|
+
effortDriven: (i % 5 === 0)
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
clearGrouping() {
|
|
189
|
+
this.dataviewObj.setGrouping([]);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
collapseAllGroups() {
|
|
193
|
+
this.dataviewObj.collapseAllGroups();
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
expandAllGroups() {
|
|
197
|
+
this.dataviewObj.expandAllGroups();
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
exportToExcel() {
|
|
201
|
+
this.excelExportService.exportToExcel({
|
|
202
|
+
filename: 'Export',
|
|
203
|
+
format: FileType.xlsx
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
exportToFile(type = 'csv') {
|
|
208
|
+
this.textExportService.exportToFile({
|
|
209
|
+
delimiter: (type === 'csv') ? DelimiterType.comma : DelimiterType.tab,
|
|
210
|
+
filename: 'myExport',
|
|
211
|
+
format: (type === 'csv') ? FileType.csv : FileType.txt
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
groupByDuration() {
|
|
216
|
+
this.dataviewObj.setGrouping({
|
|
217
|
+
getter: 'duration',
|
|
218
|
+
formatter: (g) => `Duration: ${g.value} <span style="color:green">(${g.count} items)</span>`,
|
|
219
|
+
aggregators: [
|
|
220
|
+
new Aggregators.Avg('percentComplete'),
|
|
221
|
+
new Aggregators.Sum('cost')
|
|
222
|
+
],
|
|
223
|
+
comparer: (a, b) => SortComparers.numeric(a.value, b.value, SortDirectionNumber.asc),
|
|
224
|
+
aggregateCollapsed: false,
|
|
225
|
+
lazyTotalsCalculation: true
|
|
226
|
+
} as Grouping);
|
|
227
|
+
|
|
228
|
+
// you need to manually add the sort icon(s) in UI
|
|
229
|
+
this.angularGrid.filterService.setSortColumnIcons([{ columnId: 'duration', sortAsc: true }]);
|
|
230
|
+
this.gridObj.invalidate(); // invalidate all rows and re-render
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
groupByDurationOrderByCount(aggregateCollapsed: boolean) {
|
|
234
|
+
this.angularGrid.filterService.setSortColumnIcons([]);
|
|
235
|
+
this.dataviewObj.setGrouping({
|
|
236
|
+
getter: 'duration',
|
|
237
|
+
formatter: (g) => `Duration: ${g.value} <span style="color:green">(${g.count} items)</span>`,
|
|
238
|
+
comparer: (a, b) => {
|
|
239
|
+
return a.count - b.count;
|
|
240
|
+
},
|
|
241
|
+
aggregators: [
|
|
242
|
+
new Aggregators.Avg('percentComplete'),
|
|
243
|
+
new Aggregators.Sum('cost')
|
|
244
|
+
],
|
|
245
|
+
aggregateCollapsed,
|
|
246
|
+
lazyTotalsCalculation: true
|
|
247
|
+
} as Grouping);
|
|
248
|
+
this.gridObj.invalidate(); // invalidate all rows and re-render
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
groupByDurationEffortDriven() {
|
|
252
|
+
this.angularGrid.filterService.setSortColumnIcons([]);
|
|
253
|
+
this.dataviewObj.setGrouping([
|
|
254
|
+
{
|
|
255
|
+
getter: 'duration',
|
|
256
|
+
formatter: (g) => `Duration: ${g.value} <span style="color:green">(${g.count} items)</span>`,
|
|
257
|
+
aggregators: [
|
|
258
|
+
new Aggregators.Sum('duration'),
|
|
259
|
+
new Aggregators.Sum('cost')
|
|
260
|
+
],
|
|
261
|
+
aggregateCollapsed: true,
|
|
262
|
+
lazyTotalsCalculation: true
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
getter: 'effortDriven',
|
|
266
|
+
formatter: (g) => `Effort-Driven: ${(g.value ? 'True' : 'False')} <span style="color:green">(${g.count} items)</span>`,
|
|
267
|
+
aggregators: [
|
|
268
|
+
new Aggregators.Avg('percentComplete'),
|
|
269
|
+
new Aggregators.Sum('cost')
|
|
270
|
+
],
|
|
271
|
+
collapsed: true,
|
|
272
|
+
lazyTotalsCalculation: true
|
|
273
|
+
}
|
|
274
|
+
] as Grouping[]);
|
|
275
|
+
this.gridObj.invalidate(); // invalidate all rows and re-render
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
groupByDurationEffortDrivenPercent() {
|
|
279
|
+
this.angularGrid.filterService.setSortColumnIcons([]);
|
|
280
|
+
this.dataviewObj.setGrouping([
|
|
281
|
+
{
|
|
282
|
+
getter: 'duration',
|
|
283
|
+
formatter: (g) => `Duration: ${g.value} <span style="color:green">(${g.count} items)</span>`,
|
|
284
|
+
aggregators: [
|
|
285
|
+
new Aggregators.Sum('duration'),
|
|
286
|
+
new Aggregators.Sum('cost')
|
|
287
|
+
],
|
|
288
|
+
aggregateCollapsed: true,
|
|
289
|
+
lazyTotalsCalculation: true
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
getter: 'effortDriven',
|
|
293
|
+
formatter: (g) => `Effort-Driven: ${(g.value ? 'True' : 'False')} <span style="color:green">(${g.count} items)</span>`,
|
|
294
|
+
aggregators: [
|
|
295
|
+
new Aggregators.Sum('duration'),
|
|
296
|
+
new Aggregators.Sum('cost')
|
|
297
|
+
],
|
|
298
|
+
lazyTotalsCalculation: true
|
|
299
|
+
},
|
|
300
|
+
{
|
|
301
|
+
getter: 'percentComplete',
|
|
302
|
+
formatter: (g) => `% Complete: ${g.value} <span style="color:green">(${g.count} items)</span>`,
|
|
303
|
+
aggregators: [
|
|
304
|
+
new Aggregators.Avg('percentComplete')
|
|
305
|
+
],
|
|
306
|
+
aggregateCollapsed: true,
|
|
307
|
+
collapsed: true,
|
|
308
|
+
lazyTotalsCalculation: true
|
|
309
|
+
}
|
|
310
|
+
] as Grouping[]);
|
|
311
|
+
this.gridObj.invalidate(); // invalidate all rows and re-render
|
|
312
|
+
}
|
|
313
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
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-headerbutton.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
|
+
<h5>Grid 1</h5>
|
|
15
|
+
<angular-slickgrid gridId="grid7-1"
|
|
16
|
+
[columnDefinitions]="columnDefinitions1"
|
|
17
|
+
[gridOptions]="gridOptions1"
|
|
18
|
+
[dataset]="dataset1"
|
|
19
|
+
(onAngularGridCreated)="angularGrid1Ready($event.detail)">
|
|
20
|
+
</angular-slickgrid>
|
|
21
|
+
|
|
22
|
+
<br />
|
|
23
|
+
<h5>Grid 2 - <span class="subtitle">with both Header Buttons & Menus</span></h5>
|
|
24
|
+
<angular-slickgrid gridId="grid7-2"
|
|
25
|
+
[columnDefinitions]="columnDefinitions2"
|
|
26
|
+
[gridOptions]="gridOptions2"
|
|
27
|
+
[dataset]="dataset2"
|
|
28
|
+
(onAngularGridCreated)="angularGrid2Ready($event.detail)">
|
|
29
|
+
</angular-slickgrid>
|
|
30
|
+
|
|
31
|
+
</div>
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import { Component, OnInit, ViewEncapsulation } from '@angular/core';
|
|
2
|
+
|
|
3
|
+
import { AngularGridInstance, Column, GridOption, } from './../modules/angular-slickgrid';
|
|
4
|
+
|
|
5
|
+
// create a custom Formatter to highlight negative values in red
|
|
6
|
+
let columns1WithHighlightingById: any = {};
|
|
7
|
+
let columns2WithHighlightingById: any = {};
|
|
8
|
+
|
|
9
|
+
@Component({
|
|
10
|
+
styleUrls: ['./grid-headerbutton.component.scss'],
|
|
11
|
+
encapsulation: ViewEncapsulation.None,
|
|
12
|
+
templateUrl: './grid-headerbutton.component.html'
|
|
13
|
+
})
|
|
14
|
+
export class GridHeaderButtonComponent implements OnInit {
|
|
15
|
+
title = 'Example 7: Header Button Plugin';
|
|
16
|
+
subTitle = `
|
|
17
|
+
This example demonstrates using the <b>Slick.Plugins.HeaderButtons</b> plugin to easily add buttons to colum headers.
|
|
18
|
+
These buttons can be specified directly in the column definition, and are very easy to configure and use.
|
|
19
|
+
(<a href="https://github.com/ghiscoding/Angular-Slickgrid/wiki/Header-Menu-&-Header-Buttons" target="_blank">Wiki docs</a>)
|
|
20
|
+
<ul>
|
|
21
|
+
<li>Resize the 1st column to see all icon/command</li>
|
|
22
|
+
<li>Mouse hover the 2nd column to see it's icon/command</li>
|
|
23
|
+
<li>For all the other columns, click on top-right red circle icon to enable highlight of negative numbers.</li>
|
|
24
|
+
<li>Use override callback functions to change the properties of show/hide, enable/disable the menu or certain item(s) from the list</li>
|
|
25
|
+
<ol>
|
|
26
|
+
<li>These callbacks are: "itemVisibilityOverride", "itemUsabilityOverride"</li>
|
|
27
|
+
<li>for example the "Column E" does not show the header button via "itemVisibilityOverride"</li>
|
|
28
|
+
<li>for example the "Column J" header button is displayed but it not usable via "itemUsabilityOverride"</li>
|
|
29
|
+
</ol>
|
|
30
|
+
</ul>
|
|
31
|
+
`;
|
|
32
|
+
|
|
33
|
+
columnDefinitions1: Column[] = [];
|
|
34
|
+
columnDefinitions2: Column[] = [];
|
|
35
|
+
gridOptions1!: GridOption;
|
|
36
|
+
gridOptions2!: GridOption;
|
|
37
|
+
dataset1: any[] = [];
|
|
38
|
+
dataset2: any[] = [];
|
|
39
|
+
angularGrid1!: AngularGridInstance;
|
|
40
|
+
angularGrid2!: AngularGridInstance;
|
|
41
|
+
|
|
42
|
+
constructor() {
|
|
43
|
+
columns1WithHighlightingById = {};
|
|
44
|
+
columns2WithHighlightingById = {};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
ngOnInit(): void {
|
|
48
|
+
this.defineGrid();
|
|
49
|
+
|
|
50
|
+
// populate the dataset once the grid is ready
|
|
51
|
+
this.dataset1 = this.loadData(200, 1);
|
|
52
|
+
this.dataset2 = this.loadData(200, 2);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
angularGrid1Ready(angularGrid: AngularGridInstance) {
|
|
56
|
+
this.angularGrid1 = angularGrid;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
angularGrid2Ready(angularGrid: AngularGridInstance) {
|
|
60
|
+
this.angularGrid2 = angularGrid;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
defineGrid() {
|
|
64
|
+
this.gridOptions1 = {
|
|
65
|
+
enableAutoResize: true,
|
|
66
|
+
enableHeaderButton: true,
|
|
67
|
+
enableHeaderMenu: false,
|
|
68
|
+
autoResize: {
|
|
69
|
+
container: '#demo-container',
|
|
70
|
+
rightPadding: 10
|
|
71
|
+
},
|
|
72
|
+
enableFiltering: false,
|
|
73
|
+
enableExcelCopyBuffer: true,
|
|
74
|
+
excelCopyBufferOptions: {
|
|
75
|
+
onCopyCells: (e, args) => console.log('onCopyCells', e, args),
|
|
76
|
+
onPasteCells: (e, args) => console.log('onPasteCells', e, args),
|
|
77
|
+
onCopyCancelled: (e, args) => console.log('onCopyCancelled', e, args),
|
|
78
|
+
},
|
|
79
|
+
enableCellNavigation: true,
|
|
80
|
+
gridHeight: 275,
|
|
81
|
+
headerButton: {
|
|
82
|
+
// you can use the "onCommand" (in Grid Options) and/or the "action" callback (in Column Definition)
|
|
83
|
+
onCommand: (_e, args) => this.handleOnCommand(_e, args, 1)
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
// grid 2 options, same as grid 1 + extras
|
|
88
|
+
this.gridOptions2 = {
|
|
89
|
+
...this.gridOptions1,
|
|
90
|
+
enableHeaderMenu: true,
|
|
91
|
+
enableFiltering: true,
|
|
92
|
+
// frozenColumn: 2,
|
|
93
|
+
// frozenRow: 2,
|
|
94
|
+
headerButton: {
|
|
95
|
+
// when floating to left, you might want to inverse the icon orders
|
|
96
|
+
onCommand: (_e, args) => this.handleOnCommand(_e, args, 2)
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
handleOnCommand(_e: Event, args: any, gridNo: 1 | 2) {
|
|
102
|
+
const column = args.column;
|
|
103
|
+
const button = args.button;
|
|
104
|
+
const command = args.command;
|
|
105
|
+
|
|
106
|
+
if (command === 'toggle-highlight') {
|
|
107
|
+
if (button.cssClass === 'fa fa-circle red') {
|
|
108
|
+
if (gridNo === 1) {
|
|
109
|
+
delete columns1WithHighlightingById[column.id];
|
|
110
|
+
} else {
|
|
111
|
+
delete columns2WithHighlightingById[column.id];
|
|
112
|
+
}
|
|
113
|
+
button.cssClass = 'fa fa-circle-o red faded';
|
|
114
|
+
button.tooltip = 'Highlight negative numbers.';
|
|
115
|
+
} else {
|
|
116
|
+
if (gridNo === 1) {
|
|
117
|
+
columns1WithHighlightingById[column.id] = true;
|
|
118
|
+
} else {
|
|
119
|
+
columns2WithHighlightingById[column.id] = true;
|
|
120
|
+
}
|
|
121
|
+
button.cssClass = 'fa fa-circle red';
|
|
122
|
+
button.tooltip = 'Remove highlight.';
|
|
123
|
+
}
|
|
124
|
+
((this as any)[`angularGrid${gridNo}`] as AngularGridInstance).slickGrid.invalidate();
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
loadData(count: number, gridNo: 1 | 2) {
|
|
129
|
+
// Set up some test columns.
|
|
130
|
+
for (let i = 0; i < 10; i++) {
|
|
131
|
+
(this as any)[`columnDefinitions${gridNo}`].push({
|
|
132
|
+
id: i,
|
|
133
|
+
name: 'Column ' + String.fromCharCode('A'.charCodeAt(0) + i),
|
|
134
|
+
field: i + '',
|
|
135
|
+
width: i === 0 ? 70 : 100, // have the 2 first columns wider
|
|
136
|
+
filterable: true,
|
|
137
|
+
sortable: true,
|
|
138
|
+
formatter: (_row: number, _cell: number, value: any, columnDef: Column) => {
|
|
139
|
+
if (gridNo === 1 && columns1WithHighlightingById[columnDef.id] && value < 0) {
|
|
140
|
+
return `<div style="color:red; font-weight:bold;">${value}</div>`;
|
|
141
|
+
} else if (gridNo === 2 && columns2WithHighlightingById[columnDef.id] && value < 0) {
|
|
142
|
+
return `<div style="color:red; font-weight:bold;">${value}</div>`;
|
|
143
|
+
}
|
|
144
|
+
return value;
|
|
145
|
+
},
|
|
146
|
+
header: {
|
|
147
|
+
buttons: [
|
|
148
|
+
{
|
|
149
|
+
cssClass: 'fa fa-circle-o red faded',
|
|
150
|
+
command: 'toggle-highlight',
|
|
151
|
+
tooltip: 'Highlight negative numbers.',
|
|
152
|
+
itemVisibilityOverride: (args: any) => {
|
|
153
|
+
// for example don't show the header button on column "E"
|
|
154
|
+
return args.column.name !== 'Column E';
|
|
155
|
+
},
|
|
156
|
+
itemUsabilityOverride: (args: any) => {
|
|
157
|
+
// for example the button usable everywhere except on last column ='J"
|
|
158
|
+
return args.column.name !== 'Column J';
|
|
159
|
+
},
|
|
160
|
+
action: (_e: Event, args: any) => {
|
|
161
|
+
// you can use the "action" callback and/or subscribe to the "onCallback" event, they both have the same arguments
|
|
162
|
+
// do something
|
|
163
|
+
console.log(`execute a callback action to "${args.command}" on ${args.column.name}`);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
]
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// Set multiple buttons on the first column to demonstrate overflow.
|
|
172
|
+
(this as any)[`columnDefinitions${gridNo}`][0].name = 'Resize me!';
|
|
173
|
+
(this as any)[`columnDefinitions${gridNo}`][0].header = {
|
|
174
|
+
buttons: [
|
|
175
|
+
{
|
|
176
|
+
cssClass: 'fa fa-tag',
|
|
177
|
+
handler: () => {
|
|
178
|
+
alert('Tag');
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
cssClass: 'fa fa-comment',
|
|
183
|
+
handler: () => {
|
|
184
|
+
alert('Comment');
|
|
185
|
+
}
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
cssClass: 'fa fa-info-circle',
|
|
189
|
+
handler: () => {
|
|
190
|
+
alert('Info');
|
|
191
|
+
}
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
cssClass: 'fa fa-question-circle',
|
|
195
|
+
handler: () => {
|
|
196
|
+
alert('Help');
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
]
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
// when floating to left, you might want to inverse the icon orders
|
|
203
|
+
if (gridNo === 2) {
|
|
204
|
+
this.columnDefinitions2[0].header?.buttons?.reverse();
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// Set a button on the second column to demonstrate hover.
|
|
208
|
+
(this as any)[`columnDefinitions${gridNo}`][1].name = 'Hover me!';
|
|
209
|
+
(this as any)[`columnDefinitions${gridNo}`][1].header = {
|
|
210
|
+
buttons: [
|
|
211
|
+
{
|
|
212
|
+
cssClass: 'fa fa-question-circle',
|
|
213
|
+
showOnHover: true,
|
|
214
|
+
tooltip: 'This button only appears on hover.',
|
|
215
|
+
handler: () => {
|
|
216
|
+
alert('Help');
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
]
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
// mock a dataset
|
|
223
|
+
const mockDataset = [];
|
|
224
|
+
for (let i = 0; i < count; i++) {
|
|
225
|
+
const d: any = (mockDataset[i] = {});
|
|
226
|
+
d['id'] = i;
|
|
227
|
+
for (let j = 0; j < (this as any)[`columnDefinitions${gridNo}`].length; j++) {
|
|
228
|
+
d[j] = Math.round(Math.random() * 10) - 5;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
return mockDataset;
|
|
232
|
+
}
|
|
233
|
+
}
|