• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

IgniteUI / igniteui-angular / 13949450844

19 Mar 2025 02:46PM CUT coverage: 91.638%. First build
13949450844

Pull #15523

github

web-flow
Merge 0e52e01ef into 3fb0f11cc
Pull Request #15523: Enable filtering expression `conditionName` only use. Related fixes for elements Blazor grid.

13315 of 15569 branches covered (85.52%)

4 of 4 new or added lines in 1 file covered. (100.0%)

26839 of 29288 relevant lines covered (91.64%)

34010.44 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

33.33
/projects/igniteui-angular/src/lib/grids/toolbar/grid-toolbar-exporter.component.ts
1
import { Component, Input, Output, EventEmitter, Inject, booleanAttribute } from '@angular/core';
2
import { first } from 'rxjs/operators';
3
import { BaseToolbarDirective } from './grid-toolbar.base';
4
import { IgxExcelTextDirective, IgxCSVTextDirective } from './common';
5
import {
6
    CsvFileTypes,
7
    IgxBaseExporter,
8
    IgxCsvExporterOptions,
9
    IgxCsvExporterService,
10
    IgxExcelExporterOptions,
11
    IgxExcelExporterService
12
} from '../../services/public_api';
13
import { IgxToggleDirective } from '../../directives/toggle/toggle.directive';
14
import { GridType } from '../common/grid.interface';
15
import { IgxToolbarToken } from './token';
16
import { IgxIconComponent } from '../../icon/icon.component';
17
import { IgxRippleDirective } from '../../directives/ripple/ripple.directive';
18
import { IgxButtonDirective } from '../../directives/button/button.directive';
19

20

21
export type IgxExporterOptions = IgxCsvExporterOptions | IgxExcelExporterOptions;
22

23
/* jsonAPIComplexObject */
24
/* wcAlternateName: ExporterEventArgs */
25
export interface IgxExporterEvent {
26
    exporter: IgxBaseExporter;
27
    /* alternateType: ExporterOptionsBase */
28
    options: IgxExporterOptions;
29
    grid: GridType;
30
    cancel: boolean;
31
}
32

33

34
/* blazorElement */
35
/* wcElementTag: igc-grid-toolbar-exporter */
36
/* blazorIndirectRender */
37
/* jsonAPIManageItemInMarkup */
38
/* singleInstanceIdentifier */
39
/**
40
 * Provides a pre-configured exporter component for the grid.
41
 *
42
 * @remarks
43
 * This component still needs the actual exporter service(s) provided in the DI chain
44
 * in order to export something.
45
 *
46
 * @igxModule IgxGridToolbarModule
47
 * @igxParent IgxGridToolbarComponent
48
 *
49
 */
50
@Component({
51
    selector: 'igx-grid-toolbar-exporter',
52
    templateUrl: './grid-toolbar-exporter.component.html',
53
    imports: [IgxButtonDirective, IgxRippleDirective, IgxIconComponent, IgxToggleDirective, IgxExcelTextDirective, IgxCSVTextDirective]
54
})
55
export class IgxGridToolbarExporterComponent extends BaseToolbarDirective {
2✔
56

57
    /**
58
     * Show entry for CSV export.
59
     */
60
    @Input({ transform: booleanAttribute })
61
    public exportCSV = true;
7✔
62

63
    /**
64
     * Show entry for Excel export.
65
     */
66
    @Input({ transform: booleanAttribute })
67
    public exportExcel = true;
7✔
68

69
    /**
70
     * The name for the exported file.
71
     */
72
    @Input()
73
    public filename = 'ExportedData';
7✔
74

75
    /**
76
     * Emitted when starting an export operation. Re-emitted additionally
77
     * by the grid itself.
78
     */
79
    @Output()
80
    public exportStarted = new EventEmitter<IgxExporterEvent>();
7✔
81

82
    /**
83
     * Emitted on successful ending of an export operation.
84
     */
85
    @Output()
86
    public exportEnded = new EventEmitter<void>();
7✔
87

88
    /**
89
     * Indicates whether there is an export in progress.
90
     */
91
    protected isExporting = false;
7✔
92

93
    constructor(
94
        @Inject(IgxToolbarToken) toolbar: IgxToolbarToken,
95
        private excelExporter: IgxExcelExporterService,
7✔
96
        private csvExporter: IgxCsvExporterService,
7✔
97
    ) {
98
        super(toolbar);
7✔
99
    }
100

101
    protected exportClicked(type: 'excel' | 'csv', toggleRef?: IgxToggleDirective) {
102
        toggleRef?.close();
×
103
        this.export(type);
×
104
    }
105

106
    /* alternateName: exportGrid */
107
    /**
108
     * Export the grid's data
109
     * @param type File type to export
110
     */
111
    public export(type: 'excel' | 'csv'): void {
112
        let options: IgxExporterOptions;
113
        let exporter: IgxBaseExporter;
114

115
        switch (type) {
×
116
            case 'csv':
117
                options = new IgxCsvExporterOptions(this.filename, CsvFileTypes.CSV);
×
118
                exporter = this.csvExporter;
×
119
                break;
×
120
            case 'excel':
121
                options = new IgxExcelExporterOptions(this.filename);
×
122
                exporter = this.excelExporter;
×
123
        }
124

125
        const args = { exporter, options, grid: this.grid, cancel: false } as IgxExporterEvent;
×
126

127
        this.exportStarted.emit(args);
×
128
        this.grid.toolbarExporting.emit(args);
×
129
        this.isExporting = true;
×
130
        this.toolbar.showProgress = true;
×
131

132
        if (args.cancel) {
×
133
            return;
×
134
        }
135

136
        exporter.exportEnded.pipe(first()).subscribe(() => {
×
137
            this.exportEnded.emit();
×
138
            this.isExporting = false;
×
139
            this.toolbar.showProgress = false;
×
140
        });
141

142
        exporter.export(this.grid, options);
×
143
    }
144
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc