@progress/kendo-angular-grid 13.0.2 → 13.0.3-develop.2
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/aggregates/selection-aggregate.service.d.ts +44 -0
- package/aggregates/status-bar.component.d.ts +7 -38
- package/esm2020/aggregates/selection-aggregate.service.mjs +187 -0
- package/esm2020/aggregates/status-bar.component.mjs +12 -188
- package/esm2020/grid.component.mjs +4 -3
- package/esm2020/package-metadata.mjs +2 -2
- package/esm2020/selection/cell-selection.service.mjs +11 -11
- package/esm2020/selection/selection-checkbox.directive.mjs +9 -5
- package/esm2020/selection/selection.service.mjs +14 -11
- package/fesm2015/progress-kendo-angular-grid.mjs +3760 -3750
- package/fesm2020/progress-kendo-angular-grid.mjs +2191 -2181
- package/package.json +16 -16
- package/schematics/ngAdd/index.js +3 -3
- package/selection/cell-selection.service.d.ts +3 -2
- package/selection/selection-checkbox.directive.d.ts +3 -1
- package/selection/selection.service.d.ts +3 -2
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**-----------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright © 2023 Progress Software Corporation. All rights reserved.
|
|
3
|
+
* Licensed under commercial license. See LICENSE.md in the project root for more information
|
|
4
|
+
*-------------------------------------------------------------------------------------------*/
|
|
5
|
+
import { SelectionAggregate, SelectionAggregates } from './aggregate-types';
|
|
6
|
+
import { CellSelectionItem, SelectionEvent } from '../selection/types';
|
|
7
|
+
import { RowArgs } from '../rendering/common/row-args';
|
|
8
|
+
import { ContextService } from '../common/provider.service';
|
|
9
|
+
import { ColumnInfoService } from '../common/column-info.service';
|
|
10
|
+
import { LocalDataChangesService } from '../editing/local-data-changes.service';
|
|
11
|
+
import * as i0 from "@angular/core";
|
|
12
|
+
/**
|
|
13
|
+
* @hidden
|
|
14
|
+
*/
|
|
15
|
+
interface GroupedAggregates {
|
|
16
|
+
dates?: Array<any>;
|
|
17
|
+
numbers?: Array<number>;
|
|
18
|
+
booleans?: Array<boolean>;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* @hidden
|
|
22
|
+
*/
|
|
23
|
+
export declare class CellSelectionAggregateService {
|
|
24
|
+
private ctx;
|
|
25
|
+
private dataChanges;
|
|
26
|
+
private columnInfoService;
|
|
27
|
+
data: any;
|
|
28
|
+
selectedItems: Array<CellSelectionItem | RowArgs>;
|
|
29
|
+
groupedAggregates: GroupedAggregates;
|
|
30
|
+
aggregates: SelectionAggregates;
|
|
31
|
+
constructor(ctx: ContextService, dataChanges: LocalDataChangesService, columnInfoService: ColumnInfoService);
|
|
32
|
+
isAggregateIncluded(aggregate: SelectionAggregate): boolean;
|
|
33
|
+
init(): void;
|
|
34
|
+
onSelectionChange(selectionArgs: SelectionEvent): SelectionAggregates;
|
|
35
|
+
get isRowSelection(): boolean;
|
|
36
|
+
private handleAggregateChanges;
|
|
37
|
+
private groupAggregates;
|
|
38
|
+
private calculateAggregates;
|
|
39
|
+
private handleSelectedItems;
|
|
40
|
+
private nullifyAggregates;
|
|
41
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<CellSelectionAggregateService, never>;
|
|
42
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<CellSelectionAggregateService>;
|
|
43
|
+
}
|
|
44
|
+
export {};
|
|
@@ -2,52 +2,21 @@
|
|
|
2
2
|
* Copyright © 2023 Progress Software Corporation. All rights reserved.
|
|
3
3
|
* Licensed under commercial license. See LICENSE.md in the project root for more information
|
|
4
4
|
*-------------------------------------------------------------------------------------------*/
|
|
5
|
-
import { OnDestroy, OnInit } from '@angular/core';
|
|
6
|
-
import { ContextService } from '../common/provider.service';
|
|
7
|
-
import { SelectionService } from '../selection/selection.service';
|
|
8
|
-
import { CellSelectionService } from '../selection/cell-selection.service';
|
|
9
|
-
import { SelectionAggregates } from './aggregate-types';
|
|
10
5
|
import { StatusBarTemplateDirective } from './status-bar-template.directive';
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import { ColumnInfoService } from '../common/column-info.service';
|
|
6
|
+
import { CellSelectionAggregateService } from './selection-aggregate.service';
|
|
7
|
+
import { SelectionAggregates } from './aggregate-types';
|
|
14
8
|
import * as i0 from "@angular/core";
|
|
15
|
-
interface GroupedAggregates {
|
|
16
|
-
dates?: Array<any>;
|
|
17
|
-
numbers?: Array<number>;
|
|
18
|
-
booleans?: Array<boolean>;
|
|
19
|
-
}
|
|
20
9
|
/**
|
|
21
10
|
* @hidden
|
|
22
11
|
*/
|
|
23
|
-
export declare class StatusBarComponent
|
|
24
|
-
private
|
|
25
|
-
private selectionService;
|
|
26
|
-
private dataChanges;
|
|
27
|
-
private columnInfoService;
|
|
28
|
-
private cellSelectionService;
|
|
12
|
+
export declare class StatusBarComponent {
|
|
13
|
+
private aggregateService;
|
|
29
14
|
hostClasses: boolean;
|
|
30
15
|
get isStatusBarTemplate(): string;
|
|
31
|
-
selectableSettings: SelectableSettings | boolean;
|
|
32
16
|
statusBarTemplate: StatusBarTemplateDirective;
|
|
33
|
-
|
|
34
|
-
aggregates: SelectionAggregates;
|
|
35
|
-
private data;
|
|
36
|
-
private subs;
|
|
37
|
-
private selectedItems;
|
|
38
|
-
private selectService;
|
|
39
|
-
constructor(ctx: ContextService, selectionService: SelectionService, dataChanges: LocalDataChangesService, columnInfoService: ColumnInfoService, cellSelectionService: CellSelectionService);
|
|
17
|
+
constructor(aggregateService: CellSelectionAggregateService);
|
|
40
18
|
ngOnInit(): void;
|
|
41
|
-
|
|
42
|
-
private onSelectionChange;
|
|
43
|
-
private handleAggregateChanges;
|
|
44
|
-
private groupAggregates;
|
|
45
|
-
private calculateAggregates;
|
|
46
|
-
private handleSelectedItems;
|
|
47
|
-
private isAggregateIncluded;
|
|
48
|
-
private nullifyAggregates;
|
|
49
|
-
private get isRowSelection();
|
|
19
|
+
get aggregates(): SelectionAggregates;
|
|
50
20
|
static ɵfac: i0.ɵɵFactoryDeclaration<StatusBarComponent, never>;
|
|
51
|
-
static ɵcmp: i0.ɵɵComponentDeclaration<StatusBarComponent, "kendo-grid-status-bar", never, { "
|
|
21
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<StatusBarComponent, "kendo-grid-status-bar", never, { "statusBarTemplate": "statusBarTemplate"; }, {}, never, never>;
|
|
52
22
|
}
|
|
53
|
-
export {};
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
/**-----------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright © 2023 Progress Software Corporation. All rights reserved.
|
|
3
|
+
* Licensed under commercial license. See LICENSE.md in the project root for more information
|
|
4
|
+
*-------------------------------------------------------------------------------------------*/
|
|
5
|
+
import { Injectable } from '@angular/core';
|
|
6
|
+
import { ContextService } from '../common/provider.service';
|
|
7
|
+
import { ColumnInfoService } from '../common/column-info.service';
|
|
8
|
+
import { LocalDataChangesService } from '../editing/local-data-changes.service';
|
|
9
|
+
import * as i0 from "@angular/core";
|
|
10
|
+
import * as i1 from "../common/provider.service";
|
|
11
|
+
import * as i2 from "../editing/local-data-changes.service";
|
|
12
|
+
import * as i3 from "../common/column-info.service";
|
|
13
|
+
;
|
|
14
|
+
/**
|
|
15
|
+
* @hidden
|
|
16
|
+
*/
|
|
17
|
+
export class CellSelectionAggregateService {
|
|
18
|
+
constructor(ctx, dataChanges, columnInfoService) {
|
|
19
|
+
this.ctx = ctx;
|
|
20
|
+
this.dataChanges = dataChanges;
|
|
21
|
+
this.columnInfoService = columnInfoService;
|
|
22
|
+
this.selectedItems = [];
|
|
23
|
+
this.groupedAggregates = { dates: [], numbers: [], booleans: [] };
|
|
24
|
+
this.aggregates = {
|
|
25
|
+
sum: null,
|
|
26
|
+
average: null,
|
|
27
|
+
min: null,
|
|
28
|
+
max: null,
|
|
29
|
+
count: null,
|
|
30
|
+
isTrue: null,
|
|
31
|
+
isFalse: null,
|
|
32
|
+
earliest: null,
|
|
33
|
+
latest: null
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
isAggregateIncluded(aggregate) {
|
|
37
|
+
const { cellAggregates } = this.ctx.grid.selectable;
|
|
38
|
+
if (typeof cellAggregates !== 'boolean') {
|
|
39
|
+
return cellAggregates?.includes(aggregate);
|
|
40
|
+
}
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
init() {
|
|
44
|
+
if (this.ctx.grid.selectable.cellAggregates) {
|
|
45
|
+
this.data = this.dataChanges.data ? this.dataChanges.data : this.ctx.grid.data;
|
|
46
|
+
if (this.isAggregateIncluded('count')) {
|
|
47
|
+
this.aggregates['count'] = 0;
|
|
48
|
+
}
|
|
49
|
+
const selectionDirective = this.ctx.grid.selectionDirective;
|
|
50
|
+
if (selectionDirective && !this.isRowSelection) {
|
|
51
|
+
this.selectedItems = selectionDirective.selectedKeys;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
onSelectionChange(selectionArgs) {
|
|
56
|
+
this.handleSelectedItems(selectionArgs);
|
|
57
|
+
this.nullifyAggregates();
|
|
58
|
+
this.handleAggregateChanges();
|
|
59
|
+
return this.aggregates;
|
|
60
|
+
}
|
|
61
|
+
get isRowSelection() {
|
|
62
|
+
return typeof this.ctx.grid.selectable === 'boolean' || !this.ctx.grid.selectable.cell;
|
|
63
|
+
}
|
|
64
|
+
handleAggregateChanges() {
|
|
65
|
+
const lockedColumns = this.columnInfoService.lockedLeafColumns.toArray();
|
|
66
|
+
const nonLockedColumns = this.columnInfoService.nonLockedLeafColumns.toArray();
|
|
67
|
+
const selectedItemsLength = this.selectedItems.length;
|
|
68
|
+
const columns = [...lockedColumns, ...nonLockedColumns];
|
|
69
|
+
const fields = columns.map(col => col.field);
|
|
70
|
+
if (this.isAggregateIncluded('count')) {
|
|
71
|
+
this.aggregates['count'] = this.isRowSelection ? (selectedItemsLength * columns.length) : selectedItemsLength;
|
|
72
|
+
}
|
|
73
|
+
this.selectedItems.forEach((item) => {
|
|
74
|
+
if (this.isRowSelection) {
|
|
75
|
+
fields.forEach((field) => {
|
|
76
|
+
const cellValue = item.dataItem;
|
|
77
|
+
if (cellValue && cellValue.hasOwnProperty(field)) {
|
|
78
|
+
const cellValue = item.dataItem[field];
|
|
79
|
+
this.groupAggregates(cellValue);
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
else if (!this.isRowSelection) {
|
|
84
|
+
const itemKey = this.data[item.itemKey];
|
|
85
|
+
const field = fields[item.columnKey];
|
|
86
|
+
if (itemKey && itemKey.hasOwnProperty(field)) {
|
|
87
|
+
const cellValue = itemKey[fields[item.columnKey]];
|
|
88
|
+
this.groupAggregates(cellValue);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
this.calculateAggregates();
|
|
93
|
+
}
|
|
94
|
+
groupAggregates(aggregate) {
|
|
95
|
+
if (typeof aggregate === 'number') {
|
|
96
|
+
this.groupedAggregates.numbers.push(aggregate);
|
|
97
|
+
}
|
|
98
|
+
else if (typeof aggregate === 'boolean') {
|
|
99
|
+
this.groupedAggregates.booleans.push(aggregate);
|
|
100
|
+
}
|
|
101
|
+
else if (aggregate instanceof Date) {
|
|
102
|
+
this.groupedAggregates.dates.push(aggregate);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
calculateAggregates() {
|
|
106
|
+
if (this.groupedAggregates.numbers.length > 0) {
|
|
107
|
+
if (this.isAggregateIncluded('min')) {
|
|
108
|
+
this.aggregates['min'] = Math.min(...this.groupedAggregates.numbers);
|
|
109
|
+
}
|
|
110
|
+
if (this.isAggregateIncluded('max')) {
|
|
111
|
+
this.aggregates['max'] = Math.max(...this.groupedAggregates.numbers);
|
|
112
|
+
}
|
|
113
|
+
if (this.isAggregateIncluded('sum')) {
|
|
114
|
+
this.aggregates['sum'] = this.groupedAggregates.numbers.reduce((acc, curr) => acc += curr, 0);
|
|
115
|
+
}
|
|
116
|
+
if (this.isAggregateIncluded('average')) {
|
|
117
|
+
this.aggregates['average'] = this.aggregates['sum'] / this.groupedAggregates.numbers.length;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
if (this.groupedAggregates.booleans.length > 0) {
|
|
121
|
+
if (this.isAggregateIncluded('isTrue')) {
|
|
122
|
+
const isTrueCount = this.groupedAggregates.booleans.filter(bool => bool).length;
|
|
123
|
+
this.aggregates['isTrue'] = isTrueCount > 0 ? isTrueCount : null;
|
|
124
|
+
}
|
|
125
|
+
if (this.isAggregateIncluded('isFalse')) {
|
|
126
|
+
const isFalseCount = this.groupedAggregates.booleans.length - this.aggregates['isTrue'];
|
|
127
|
+
this.aggregates['isFalse'] = isFalseCount > 0 ? isFalseCount : null;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
if (this.groupedAggregates.dates.length > 0) {
|
|
131
|
+
if (this.isAggregateIncluded('earliest')) {
|
|
132
|
+
this.aggregates['earliest'] = new Date(Math.min(...this.groupedAggregates.dates));
|
|
133
|
+
}
|
|
134
|
+
if (this.isAggregateIncluded('latest')) {
|
|
135
|
+
this.aggregates['latest'] = new Date(Math.max(...this.groupedAggregates.dates));
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
handleSelectedItems(selectionArgs) {
|
|
140
|
+
const rowOrCellSelect = `${this.isRowSelection ? 'selectedRows' : 'selectedCells'}`;
|
|
141
|
+
const rowOrCellDeselect = `${this.isRowSelection ? 'deselectedRows' : 'deselectedCells'}`;
|
|
142
|
+
const selectedItems = selectionArgs[rowOrCellSelect];
|
|
143
|
+
const deselectedItems = selectionArgs[rowOrCellDeselect];
|
|
144
|
+
if (!this.isRowSelection) {
|
|
145
|
+
// Needed when we have column groups with cell selection, the deselected items are duplicated
|
|
146
|
+
deselectedItems.forEach((item, index) => {
|
|
147
|
+
if (index + 1 < deselectedItems.length) {
|
|
148
|
+
if (item.itemKey === deselectedItems[index + 1].itemKey
|
|
149
|
+
&& item.columnKey === deselectedItems[index + 1].columnKey) {
|
|
150
|
+
deselectedItems.splice(index, 1);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
if (selectedItems.length > 0) {
|
|
156
|
+
selectedItems.forEach((item) => {
|
|
157
|
+
this.selectedItems = [...this.selectedItems, item];
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
if (deselectedItems.length > 0) {
|
|
161
|
+
if (this.isRowSelection) {
|
|
162
|
+
deselectedItems.forEach((row) => {
|
|
163
|
+
this.selectedItems = this.selectedItems.filter((elem) => elem.dataItem !== row.dataItem);
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
deselectedItems.forEach((cell) => {
|
|
168
|
+
const index = this.selectedItems.findIndex((elem) => elem.itemKey === cell.itemKey && elem.columnKey === cell.columnKey);
|
|
169
|
+
this.selectedItems.splice(index, 1);
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
nullifyAggregates() {
|
|
175
|
+
this.groupedAggregates = { dates: [], numbers: [], booleans: [] };
|
|
176
|
+
this.aggregates['count'] = null;
|
|
177
|
+
this.aggregates['sum'] = this.aggregates['average'] = null;
|
|
178
|
+
this.aggregates['max'] = this.aggregates['min'] = null;
|
|
179
|
+
this.aggregates['isFalse'] = this.aggregates['isTrue'] = null;
|
|
180
|
+
this.aggregates['earliest'] = this.aggregates['latest'] = null;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
CellSelectionAggregateService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: CellSelectionAggregateService, deps: [{ token: i1.ContextService }, { token: i2.LocalDataChangesService }, { token: i3.ColumnInfoService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
184
|
+
CellSelectionAggregateService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: CellSelectionAggregateService });
|
|
185
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: CellSelectionAggregateService, decorators: [{
|
|
186
|
+
type: Injectable
|
|
187
|
+
}], ctorParameters: function () { return [{ type: i1.ContextService }, { type: i2.LocalDataChangesService }, { type: i3.ColumnInfoService }]; } });
|
|
@@ -2,212 +2,38 @@
|
|
|
2
2
|
* Copyright © 2023 Progress Software Corporation. All rights reserved.
|
|
3
3
|
* Licensed under commercial license. See LICENSE.md in the project root for more information
|
|
4
4
|
*-------------------------------------------------------------------------------------------*/
|
|
5
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
6
5
|
import { Component, HostBinding, Input } from '@angular/core';
|
|
7
|
-
import { Subscription } from 'rxjs';
|
|
8
|
-
import { ContextService } from '../common/provider.service';
|
|
9
|
-
import { SelectionService } from '../selection/selection.service';
|
|
10
|
-
import { CellSelectionService } from '../selection/cell-selection.service';
|
|
11
6
|
import { StatusBarTemplateDirective } from './status-bar-template.directive';
|
|
12
|
-
import {
|
|
13
|
-
import { ColumnInfoService } from '../common/column-info.service';
|
|
7
|
+
import { CellSelectionAggregateService } from './selection-aggregate.service';
|
|
14
8
|
import * as i0 from "@angular/core";
|
|
15
|
-
import * as i1 from "
|
|
16
|
-
import * as i2 from "
|
|
17
|
-
import * as i3 from "../editing/local-data-changes.service";
|
|
18
|
-
import * as i4 from "../common/column-info.service";
|
|
19
|
-
import * as i5 from "../selection/cell-selection.service";
|
|
20
|
-
import * as i6 from "@angular/common";
|
|
21
|
-
;
|
|
9
|
+
import * as i1 from "./selection-aggregate.service";
|
|
10
|
+
import * as i2 from "@angular/common";
|
|
22
11
|
/**
|
|
23
12
|
* @hidden
|
|
24
13
|
*/
|
|
25
14
|
export class StatusBarComponent {
|
|
26
|
-
constructor(
|
|
27
|
-
this.
|
|
28
|
-
this.selectionService = selectionService;
|
|
29
|
-
this.dataChanges = dataChanges;
|
|
30
|
-
this.columnInfoService = columnInfoService;
|
|
31
|
-
this.cellSelectionService = cellSelectionService;
|
|
15
|
+
constructor(aggregateService) {
|
|
16
|
+
this.aggregateService = aggregateService;
|
|
32
17
|
this.hostClasses = true;
|
|
33
|
-
this.groupedAggregates = { dates: [], numbers: [], booleans: [] };
|
|
34
|
-
this.aggregates = {
|
|
35
|
-
sum: null,
|
|
36
|
-
average: null,
|
|
37
|
-
min: null,
|
|
38
|
-
max: null,
|
|
39
|
-
count: null,
|
|
40
|
-
isTrue: null,
|
|
41
|
-
isFalse: null,
|
|
42
|
-
earliest: null,
|
|
43
|
-
latest: null
|
|
44
|
-
};
|
|
45
|
-
this.subs = new Subscription();
|
|
46
|
-
this.selectedItems = [];
|
|
47
18
|
}
|
|
48
19
|
get isStatusBarTemplate() {
|
|
49
20
|
return this.statusBarTemplate ? '' : 'none';
|
|
50
21
|
}
|
|
51
22
|
ngOnInit() {
|
|
52
|
-
|
|
53
|
-
this.data = this.dataChanges.data ? this.dataChanges.data : this.ctx.grid.data;
|
|
54
|
-
this.selectService = this.isRowSelection ? this.selectionService : this.cellSelectionService;
|
|
55
|
-
if (this.isAggregateIncluded('count')) {
|
|
56
|
-
this.aggregates['count'] = 0;
|
|
57
|
-
}
|
|
58
|
-
const selectionDirective = this.ctx.grid.selectionDirective;
|
|
59
|
-
if (selectionDirective && !this.isRowSelection) {
|
|
60
|
-
this.selectedItems = selectionDirective.selectedKeys;
|
|
61
|
-
}
|
|
62
|
-
this.subs.add(this.selectService.aggregateChanges.subscribe((selectionArgs) => this.onSelectionChange(selectionArgs)));
|
|
63
|
-
}
|
|
23
|
+
this.aggregateService.init();
|
|
64
24
|
}
|
|
65
|
-
|
|
66
|
-
this.
|
|
67
|
-
}
|
|
68
|
-
onSelectionChange(selectionArgs) {
|
|
69
|
-
this.handleSelectedItems(selectionArgs);
|
|
70
|
-
this.nullifyAggregates();
|
|
71
|
-
this.handleAggregateChanges();
|
|
72
|
-
this.selectService.aggregates = this.aggregates;
|
|
73
|
-
}
|
|
74
|
-
handleAggregateChanges() {
|
|
75
|
-
const lockedColumns = this.columnInfoService.lockedLeafColumns.toArray();
|
|
76
|
-
const nonLockedColumns = this.columnInfoService.nonLockedLeafColumns.toArray();
|
|
77
|
-
const selectedItemsLength = this.selectedItems.length;
|
|
78
|
-
const columns = [...lockedColumns, ...nonLockedColumns];
|
|
79
|
-
const fields = columns.map(col => col.field);
|
|
80
|
-
if (this.isAggregateIncluded('count')) {
|
|
81
|
-
this.aggregates['count'] = this.isRowSelection ? (selectedItemsLength * columns.length) : selectedItemsLength;
|
|
82
|
-
}
|
|
83
|
-
this.selectedItems.forEach((item) => {
|
|
84
|
-
if (this.isRowSelection) {
|
|
85
|
-
fields.forEach((field) => {
|
|
86
|
-
const cellValue = item.dataItem;
|
|
87
|
-
if (cellValue && cellValue.hasOwnProperty(field)) {
|
|
88
|
-
const cellValue = item.dataItem[field];
|
|
89
|
-
this.groupAggregates(cellValue);
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
else if (this.selectService.options.cell) {
|
|
94
|
-
const itemKey = this.data[item.itemKey];
|
|
95
|
-
const field = fields[item.columnKey];
|
|
96
|
-
if (itemKey && itemKey.hasOwnProperty(field)) {
|
|
97
|
-
const cellValue = itemKey[fields[item.columnKey]];
|
|
98
|
-
this.groupAggregates(cellValue);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
this.calculateAggregates();
|
|
103
|
-
}
|
|
104
|
-
groupAggregates(aggregate) {
|
|
105
|
-
if (typeof aggregate === 'number') {
|
|
106
|
-
this.groupedAggregates.numbers.push(aggregate);
|
|
107
|
-
}
|
|
108
|
-
else if (typeof aggregate === 'boolean') {
|
|
109
|
-
this.groupedAggregates.booleans.push(aggregate);
|
|
110
|
-
}
|
|
111
|
-
else if (aggregate instanceof Date) {
|
|
112
|
-
this.groupedAggregates.dates.push(aggregate);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
calculateAggregates() {
|
|
116
|
-
if (this.groupedAggregates.numbers.length > 0) {
|
|
117
|
-
if (this.isAggregateIncluded('min')) {
|
|
118
|
-
this.aggregates['min'] = Math.min(...this.groupedAggregates.numbers);
|
|
119
|
-
}
|
|
120
|
-
if (this.isAggregateIncluded('max')) {
|
|
121
|
-
this.aggregates['max'] = Math.max(...this.groupedAggregates.numbers);
|
|
122
|
-
}
|
|
123
|
-
if (this.isAggregateIncluded('sum')) {
|
|
124
|
-
this.aggregates['sum'] = this.groupedAggregates.numbers.reduce((acc, curr) => acc += curr, 0);
|
|
125
|
-
}
|
|
126
|
-
if (this.isAggregateIncluded('average')) {
|
|
127
|
-
this.aggregates['average'] = this.aggregates['sum'] / this.groupedAggregates.numbers.length;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
if (this.groupedAggregates.booleans.length > 0) {
|
|
131
|
-
if (this.isAggregateIncluded('isTrue')) {
|
|
132
|
-
const isTrueCount = this.groupedAggregates.booleans.filter(bool => bool).length;
|
|
133
|
-
this.aggregates['isTrue'] = isTrueCount > 0 ? isTrueCount : null;
|
|
134
|
-
}
|
|
135
|
-
if (this.isAggregateIncluded('isFalse')) {
|
|
136
|
-
const isFalseCount = this.groupedAggregates.booleans.length - this.aggregates['isTrue'];
|
|
137
|
-
this.aggregates['isFalse'] = isFalseCount > 0 ? isFalseCount : null;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
if (this.groupedAggregates.dates.length > 0) {
|
|
141
|
-
if (this.isAggregateIncluded('earliest')) {
|
|
142
|
-
this.aggregates['earliest'] = new Date(Math.min(...this.groupedAggregates.dates));
|
|
143
|
-
}
|
|
144
|
-
if (this.isAggregateIncluded('latest')) {
|
|
145
|
-
this.aggregates['latest'] = new Date(Math.max(...this.groupedAggregates.dates));
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
handleSelectedItems(selectionArgs) {
|
|
150
|
-
const rowOrCellSelect = `${this.isRowSelection ? 'selectedRows' : 'selectedCells'}`;
|
|
151
|
-
const rowOrCellDeselect = `${this.isRowSelection ? 'deselectedRows' : 'deselectedCells'}`;
|
|
152
|
-
const selectedItems = selectionArgs[rowOrCellSelect];
|
|
153
|
-
const deselectedItems = selectionArgs[rowOrCellDeselect];
|
|
154
|
-
if (!this.isRowSelection) {
|
|
155
|
-
// Needed when we have column groups with cell selection, the deselected items are duplicated
|
|
156
|
-
deselectedItems.forEach((item, index) => {
|
|
157
|
-
if (index + 1 < deselectedItems.length) {
|
|
158
|
-
if (item.itemKey === deselectedItems[index + 1].itemKey
|
|
159
|
-
&& item.columnKey === deselectedItems[index + 1].columnKey) {
|
|
160
|
-
deselectedItems.splice(index, 1);
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
if (selectedItems.length > 0) {
|
|
166
|
-
selectedItems.forEach((item) => {
|
|
167
|
-
this.selectedItems = [...this.selectedItems, item];
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
if (deselectedItems.length > 0) {
|
|
171
|
-
if (this.isRowSelection) {
|
|
172
|
-
deselectedItems.forEach((row) => {
|
|
173
|
-
this.selectedItems = this.selectedItems.filter((elem) => elem.dataItem !== row.dataItem);
|
|
174
|
-
});
|
|
175
|
-
}
|
|
176
|
-
else {
|
|
177
|
-
deselectedItems.forEach((cell) => {
|
|
178
|
-
const index = this.selectedItems.findIndex((elem) => elem.itemKey === cell.itemKey && elem.columnKey === cell.columnKey);
|
|
179
|
-
this.selectedItems.splice(index, 1);
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
isAggregateIncluded(aggregate) {
|
|
185
|
-
const { cellAggregates } = this.selectService.options;
|
|
186
|
-
if (typeof cellAggregates !== 'boolean') {
|
|
187
|
-
return cellAggregates.includes(aggregate);
|
|
188
|
-
}
|
|
189
|
-
return true;
|
|
190
|
-
}
|
|
191
|
-
nullifyAggregates() {
|
|
192
|
-
this.groupedAggregates = { dates: [], numbers: [], booleans: [] };
|
|
193
|
-
this.aggregates['count'] = null;
|
|
194
|
-
this.aggregates['sum'] = this.aggregates['average'] = null;
|
|
195
|
-
this.aggregates['max'] = this.aggregates['min'] = null;
|
|
196
|
-
this.aggregates['isFalse'] = this.aggregates['isTrue'] = null;
|
|
197
|
-
this.aggregates['earliest'] = this.aggregates['latest'] = null;
|
|
198
|
-
}
|
|
199
|
-
get isRowSelection() {
|
|
200
|
-
return typeof this.selectableSettings === 'boolean' || !this.selectableSettings.cell;
|
|
25
|
+
get aggregates() {
|
|
26
|
+
return this.aggregateService.aggregates;
|
|
201
27
|
}
|
|
202
28
|
}
|
|
203
|
-
StatusBarComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: StatusBarComponent, deps: [{ token: i1.
|
|
204
|
-
StatusBarComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.12", type: StatusBarComponent, selector: "kendo-grid-status-bar", inputs: {
|
|
29
|
+
StatusBarComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: StatusBarComponent, deps: [{ token: i1.CellSelectionAggregateService }], target: i0.ɵɵFactoryTarget.Component });
|
|
30
|
+
StatusBarComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.12", type: StatusBarComponent, selector: "kendo-grid-status-bar", inputs: { statusBarTemplate: "statusBarTemplate" }, host: { properties: { "class.k-selection-aggregates": "this.hostClasses", "class.k-grid-selection-aggregates": "this.hostClasses", "style.display": "this.isStatusBarTemplate" } }, ngImport: i0, template: `
|
|
205
31
|
<ng-template
|
|
206
32
|
*ngIf="statusBarTemplate"
|
|
207
33
|
[ngTemplateOutlet]="statusBarTemplate?.templateRef"
|
|
208
34
|
[ngTemplateOutletContext]="{ aggregates: aggregates }">
|
|
209
35
|
</ng-template>
|
|
210
|
-
`, isInline: true, directives: [{ type:
|
|
36
|
+
`, isInline: true, directives: [{ type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i2.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }] });
|
|
211
37
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: StatusBarComponent, decorators: [{
|
|
212
38
|
type: Component,
|
|
213
39
|
args: [{
|
|
@@ -220,7 +46,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImpo
|
|
|
220
46
|
</ng-template>
|
|
221
47
|
`
|
|
222
48
|
}]
|
|
223
|
-
}], ctorParameters: function () { return [{ type: i1.
|
|
49
|
+
}], ctorParameters: function () { return [{ type: i1.CellSelectionAggregateService }]; }, propDecorators: { hostClasses: [{
|
|
224
50
|
type: HostBinding,
|
|
225
51
|
args: ['class.k-selection-aggregates']
|
|
226
52
|
}, {
|
|
@@ -229,8 +55,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImpo
|
|
|
229
55
|
}], isStatusBarTemplate: [{
|
|
230
56
|
type: HostBinding,
|
|
231
57
|
args: ['style.display']
|
|
232
|
-
}], selectableSettings: [{
|
|
233
|
-
type: Input
|
|
234
58
|
}], statusBarTemplate: [{
|
|
235
59
|
type: Input
|
|
236
60
|
}] } });
|
|
@@ -76,6 +76,7 @@ import { guid } from '@progress/kendo-angular-common';
|
|
|
76
76
|
import { DragTargetContainerDirective, DropTargetContainerDirective } from '@progress/kendo-angular-utils';
|
|
77
77
|
import { RowReorderService } from './row-reordering/row-reorder.service';
|
|
78
78
|
import { StatusBarTemplateDirective } from './aggregates/status-bar-template.directive';
|
|
79
|
+
import { CellSelectionAggregateService } from './aggregates/selection-aggregate.service';
|
|
79
80
|
import * as i0 from "@angular/core";
|
|
80
81
|
import * as i1 from "./layout/browser-support.service";
|
|
81
82
|
import * as i2 from "./selection/selection.service";
|
|
@@ -2015,6 +2016,7 @@ GridComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version:
|
|
|
2015
2016
|
NavigationService,
|
|
2016
2017
|
FocusRoot,
|
|
2017
2018
|
IdService,
|
|
2019
|
+
CellSelectionAggregateService,
|
|
2018
2020
|
ScrollRequestService,
|
|
2019
2021
|
SortService,
|
|
2020
2022
|
ContextService,
|
|
@@ -2551,7 +2553,6 @@ GridComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version:
|
|
|
2551
2553
|
</div>
|
|
2552
2554
|
<kendo-grid-status-bar
|
|
2553
2555
|
*ngIf="showStatusBar"
|
|
2554
|
-
[selectableSettings]="selectable"
|
|
2555
2556
|
[statusBarTemplate]="statusBarTemplate">
|
|
2556
2557
|
</kendo-grid-status-bar>
|
|
2557
2558
|
<kendo-pager
|
|
@@ -2585,7 +2586,7 @@ GridComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version:
|
|
|
2585
2586
|
</kendo-icon-wrapper>
|
|
2586
2587
|
{{hintText}}
|
|
2587
2588
|
</ng-template>
|
|
2588
|
-
`, isInline: true, components: [{ type: i25.ToolbarComponent, selector: "kendo-grid-toolbar", inputs: ["position", "size", "navigable"] }, { type: i26.PagerComponent, selector: "kendo-pager", inputs: ["total", "skip", "pageSize", "options", "size", "template"], outputs: ["pageChange"] }, { type: i27.GroupPanelComponent, selector: "kendo-grid-group-panel", inputs: ["text", "navigable", "groups"], outputs: ["change"] }, { type: i28.ColGroupComponent, selector: "[kendoGridColGroup]", inputs: ["columns", "groups", "detailTemplate", "sort"] }, { type: i29.HeaderComponent, selector: "[kendoGridHeader]", inputs: ["totalColumnLevels", "columns", "groups", "detailTemplate", "scrollable", "filterable", "sort", "filter", "sortable", "groupable", "lockedColumnsCount", "resizable", "reorderable", "columnMenu", "columnMenuTemplate", "totalColumnsCount", "tabIndex", "size"] }, { type: i30.ListComponent, selector: "kendo-grid-list", inputs: ["data", "groups", "total", "rowHeight", "stickyRowHeight", "detailRowHeight", "take", "skip", "columns", "detailTemplate", "noRecordsTemplate", "selectable", "groupable", "filterable", "rowClass", "rowSticky", "loading", "trackBy", "virtualColumns", "isVirtual", "cellLoadingTemplate", "loadingTemplate", "sort", "size"], outputs: ["contentScroll", "pageChange", "scrollBottom"] }, { type: i31.FooterComponent, selector: "[kendoGridFooter]", inputs: ["columns", "groups", "detailTemplate", "scrollable", "lockedColumnsCount", "logicalRowIndex"] }, { type: i32.TableBodyComponent, selector: "[kendoGridTableBody]", inputs: ["columns", "allColumns", "groups", "detailTemplate", "noRecordsTemplate", "data", "skip", "selectable", "filterable", "noRecordsText", "isLocked", "isLoading", "isVirtual", "cellLoadingTemplate", "skipGroupDecoration", "showGroupFooters", "lockedColumnsCount", "totalColumnsCount", "virtualColumns", "trackBy", "rowSticky", "rowClass"] }, { type: i33.LoadingComponent, selector: "[kendoGridLoading]", inputs: ["loadingTemplate"] }, { type: i34.StatusBarComponent, selector: "kendo-grid-status-bar", inputs: ["
|
|
2589
|
+
`, isInline: true, components: [{ type: i25.ToolbarComponent, selector: "kendo-grid-toolbar", inputs: ["position", "size", "navigable"] }, { type: i26.PagerComponent, selector: "kendo-pager", inputs: ["total", "skip", "pageSize", "options", "size", "template"], outputs: ["pageChange"] }, { type: i27.GroupPanelComponent, selector: "kendo-grid-group-panel", inputs: ["text", "navigable", "groups"], outputs: ["change"] }, { type: i28.ColGroupComponent, selector: "[kendoGridColGroup]", inputs: ["columns", "groups", "detailTemplate", "sort"] }, { type: i29.HeaderComponent, selector: "[kendoGridHeader]", inputs: ["totalColumnLevels", "columns", "groups", "detailTemplate", "scrollable", "filterable", "sort", "filter", "sortable", "groupable", "lockedColumnsCount", "resizable", "reorderable", "columnMenu", "columnMenuTemplate", "totalColumnsCount", "tabIndex", "size"] }, { type: i30.ListComponent, selector: "kendo-grid-list", inputs: ["data", "groups", "total", "rowHeight", "stickyRowHeight", "detailRowHeight", "take", "skip", "columns", "detailTemplate", "noRecordsTemplate", "selectable", "groupable", "filterable", "rowClass", "rowSticky", "loading", "trackBy", "virtualColumns", "isVirtual", "cellLoadingTemplate", "loadingTemplate", "sort", "size"], outputs: ["contentScroll", "pageChange", "scrollBottom"] }, { type: i31.FooterComponent, selector: "[kendoGridFooter]", inputs: ["columns", "groups", "detailTemplate", "scrollable", "lockedColumnsCount", "logicalRowIndex"] }, { type: i32.TableBodyComponent, selector: "[kendoGridTableBody]", inputs: ["columns", "allColumns", "groups", "detailTemplate", "noRecordsTemplate", "data", "skip", "selectable", "filterable", "noRecordsText", "isLocked", "isLoading", "isVirtual", "cellLoadingTemplate", "skipGroupDecoration", "showGroupFooters", "lockedColumnsCount", "totalColumnsCount", "virtualColumns", "trackBy", "rowSticky", "rowClass"] }, { type: i33.LoadingComponent, selector: "[kendoGridLoading]", inputs: ["loadingTemplate"] }, { type: i34.StatusBarComponent, selector: "kendo-grid-status-bar", inputs: ["statusBarTemplate"] }, { type: i35.IconWrapperComponent, selector: "kendo-icon-wrapper", inputs: ["name", "svgIcon", "innerCssClass", "customFontClass", "size"], exportAs: ["kendoIconWrapper"] }], directives: [{ type: i36.LocalizedMessagesDirective, selector: "[kendoGridLocalizedMessages]" }, { type: i37.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i38.TableDirective, selector: "table", inputs: ["locked", "virtualColumns"] }, { type: i39.GridTableDirective, selector: "[kendoGridTable]", inputs: ["size"] }, { type: i40.ResizableContainerDirective, selector: "[kendoGridResizableContainer]", inputs: ["lockedWidth", "kendoGridResizableContainer"] }, { type: i41.DragTargetContainerDirective, selector: "[kendoDragTargetContainer]", inputs: ["hint", "dragTargetFilter", "dragHandle", "dragDelay", "threshold", "dragTargetId", "dragData", "dragDisabled", "mode"], outputs: ["onDragReady", "onPress", "onDragStart", "onDrag", "onRelease", "onDragEnd"], exportAs: ["kendoDragTargetContainer"] }, { type: i41.DropTargetContainerDirective, selector: "[kendoDropTargetContainer]", inputs: ["dropTargetFilter", "dropDisabled"], outputs: ["onDragEnter", "onDragOver", "onDragLeave", "onDrop"], exportAs: ["kendoDropTargetContainer"] }, { type: i42.DraggableDirective, selector: "[kendoDraggable]", inputs: ["enableDrag"], outputs: ["kendoPress", "kendoDrag", "kendoRelease"] }, { type: i43.GridMarqueeDirective, selector: "[kendoGridSelectionMarquee]" }], encapsulation: i0.ViewEncapsulation.None });
|
|
2589
2590
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: GridComponent, decorators: [{
|
|
2590
2591
|
type: Component,
|
|
2591
2592
|
args: [{
|
|
@@ -2629,6 +2630,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImpo
|
|
|
2629
2630
|
NavigationService,
|
|
2630
2631
|
FocusRoot,
|
|
2631
2632
|
IdService,
|
|
2633
|
+
CellSelectionAggregateService,
|
|
2632
2634
|
ScrollRequestService,
|
|
2633
2635
|
SortService,
|
|
2634
2636
|
ContextService,
|
|
@@ -3167,7 +3169,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImpo
|
|
|
3167
3169
|
</div>
|
|
3168
3170
|
<kendo-grid-status-bar
|
|
3169
3171
|
*ngIf="showStatusBar"
|
|
3170
|
-
[selectableSettings]="selectable"
|
|
3171
3172
|
[statusBarTemplate]="statusBarTemplate">
|
|
3172
3173
|
</kendo-grid-status-bar>
|
|
3173
3174
|
<kendo-pager
|
|
@@ -9,7 +9,7 @@ export const packageMetadata = {
|
|
|
9
9
|
name: '@progress/kendo-angular-grid',
|
|
10
10
|
productName: 'Kendo UI for Angular',
|
|
11
11
|
productCodes: ['KENDOUIANGULAR', 'KENDOUICOMPLETE'],
|
|
12
|
-
publishDate:
|
|
13
|
-
version: '13.0.2',
|
|
12
|
+
publishDate: 1686318734,
|
|
13
|
+
version: '13.0.3-develop.2',
|
|
14
14
|
licensingDocsUrl: 'https://www.telerik.com/kendo-angular-ui/my-license/'
|
|
15
15
|
};
|