4
4
HostBinding ,
5
5
Input ,
6
6
Optional ,
7
- ViewChild
7
+ ViewChild ,
8
+ ElementRef
8
9
} from '@angular/core' ;
9
10
10
11
import { IgxToggleDirective } from '../directives/toggle/toggle.directive' ;
@@ -13,11 +14,14 @@ import { CsvFileTypes,
13
14
IgxCsvExporterOptions ,
14
15
IgxCsvExporterService ,
15
16
IgxExcelExporterOptions ,
16
- IgxExcelExporterService } from '../services/index' ;
17
+ IgxExcelExporterService ,
18
+ CloseScrollStrategy } from '../services/index' ;
17
19
import { IgxGridAPIService } from './api.service' ;
18
20
import { IgxGridComponent } from './grid.component' ;
19
21
import { IgxDropDownComponent } from '../drop-down/drop-down.component' ;
20
22
import { IgxColumnHidingComponent } from './column-hiding.component' ;
23
+ import { OverlaySettings , PositionSettings , HorizontalAlignment , VerticalAlignment } from '../services/overlay/utilities' ;
24
+ import { ConnectedPositioningStrategy } from '../services/overlay/position' ;
21
25
22
26
@Component ( {
23
27
selector : 'igx-grid-toolbar' ,
@@ -29,15 +33,21 @@ export class IgxGridToolbarComponent {
29
33
@Input ( )
30
34
public gridID : string ;
31
35
32
- @ViewChild ( IgxToggleDirective , { read : IgxToggleDirective } )
33
- protected toggleDirective : IgxToggleDirective ;
34
-
35
36
@ViewChild ( 'columnHidingDropdown' , { read : IgxDropDownComponent } )
36
37
public columnHidingDropdown : IgxDropDownComponent ;
37
38
38
39
@ViewChild ( IgxColumnHidingComponent )
39
40
public columnHidingUI : IgxColumnHidingComponent ;
40
41
42
+ @ViewChild ( 'columnHidingButton' )
43
+ public columnHidingButton ;
44
+
45
+ @ViewChild ( 'exportDropdown' , { read : IgxDropDownComponent } )
46
+ public exportDropdown : IgxDropDownComponent ;
47
+
48
+ @ViewChild ( 'btnExport' )
49
+ public exportButton ;
50
+
41
51
public get grid ( ) : IgxGridComponent {
42
52
return this . gridAPI . get ( this . gridID ) ;
43
53
}
@@ -60,6 +70,21 @@ export class IgxGridToolbarComponent {
60
70
@Optional ( ) public csvExporter : IgxCsvExporterService ) {
61
71
}
62
72
73
+ private _positionSettings : PositionSettings = {
74
+ horizontalDirection : HorizontalAlignment . Left ,
75
+ horizontalStartPoint : HorizontalAlignment . Right ,
76
+ verticalDirection : VerticalAlignment . Bottom ,
77
+ verticalStartPoint : VerticalAlignment . Bottom
78
+ } ;
79
+
80
+ private _overlaySettings : OverlaySettings = {
81
+ positionStrategy : new ConnectedPositioningStrategy ( this . _positionSettings ) ,
82
+ scrollStrategy : new CloseScrollStrategy ( ) ,
83
+ modal : false ,
84
+ closeOnOutsideClick : true
85
+ } ;
86
+
87
+
63
88
public getTitle ( ) : string {
64
89
return this . grid != null ? this . grid . toolbarTitle : '' ;
65
90
}
@@ -77,7 +102,9 @@ export class IgxGridToolbarComponent {
77
102
}
78
103
79
104
public exportClicked ( ) {
80
- this . toggleDirective . collapsed = ! this . toggleDirective . collapsed ;
105
+
106
+ this . _overlaySettings . positionStrategy . settings . target = this . exportButton . nativeElement ;
107
+ this . exportDropdown . toggle ( this . _overlaySettings ) ;
81
108
}
82
109
83
110
public exportToExcelClicked ( ) {
@@ -106,6 +133,7 @@ export class IgxGridToolbarComponent {
106
133
}
107
134
108
135
public toggleColumnHidingUI ( ) {
109
- this . columnHidingDropdown . toggle ( ) ;
136
+ this . _overlaySettings . positionStrategy . settings . target = this . columnHidingButton . nativeElement ;
137
+ this . columnHidingDropdown . toggle ( this . _overlaySettings ) ;
110
138
}
111
139
}
0 commit comments