-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathgrid-summary-export.component.ts
More file actions
59 lines (51 loc) · 2 KB
/
grid-summary-export.component.ts
File metadata and controls
59 lines (51 loc) · 2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import { Component, ViewChild, inject } from '@angular/core';
import { ColumnType, IgxSummaryResult } from 'igniteui-angular/core';
import { IgxGridComponent } from 'igniteui-angular/grids/grid';
import {
IgxCellHeaderTemplateDirective,
IgxCellTemplateDirective,
IgxColumnComponent,
IgxNumberSummaryOperand,
IgxExcelExporterOptions,
IgxExcelExporterService
} from 'igniteui-angular/grids/core';
import { IgxButtonDirective } from 'igniteui-angular/directives';
import { IgxIconComponent } from 'igniteui-angular/icon';
import { DATA } from '../../data/nwindData';
import { IgxPreventDocumentScrollDirective } from '../../directives/prevent-scroll.directive';
import { DatePipe } from '@angular/common';
class MySummary {
public operate(data?: any[]): IgxSummaryResult[] {
const result = new IgxNumberSummaryOperand().operate(data);
result.push({
key: 'test',
label: 'Test',
summaryResult: data.filter((rec) => rec > 10 && rec < 30).length
});
return result;
}
}
@Component({
selector: 'app-grid-summary-export',
styleUrls: ['./grid-summary-export.component.scss'],
templateUrl: './grid-summary-export.component.html',
imports: [IgxButtonDirective, IgxGridComponent, IgxPreventDocumentScrollDirective, IgxColumnComponent, IgxCellTemplateDirective, IgxCellHeaderTemplateDirective, IgxIconComponent, DatePipe]
})
export class GridSummaryExportComponent {
private excelExportService = inject(IgxExcelExporterService);
@ViewChild('grid', { read: IgxGridComponent, static: true })
public grid: IgxGridComponent;
public mySummary = MySummary;
public data;
public productId = 0;
constructor() {
this.data = DATA;
this.productId = DATA.length;
}
public toggleSummary(column: ColumnType) {
column.hasSummary = !column.hasSummary;
}
public exportButtonHandler() {
this.excelExportService.export(this.grid, new IgxExcelExporterOptions('ExportedFile'));
}
}