-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathgrid-toolbar-pinning-both-sides.component.ts
More file actions
73 lines (66 loc) · 2.81 KB
/
grid-toolbar-pinning-both-sides.component.ts
File metadata and controls
73 lines (66 loc) · 2.81 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import { Component, ViewChild, ViewEncapsulation, OnInit, inject } from '@angular/core';
import { NgClass } from '@angular/common';
import { IPinningConfig, IgxColumnComponent, IgxGridToolbarActionsComponent, IgxGridToolbarComponent } from 'igniteui-angular/grids/core';
import { IgxGridComponent } from 'igniteui-angular/grids/grid';
import { IgxButtonDirective } from 'igniteui-angular/directives';
import { ColumnPinningPosition } from 'igniteui-angular/core';
import { DATA } from '../../data/customers';
import { IgxPreventDocumentScrollDirective } from '../../directives/prevent-scroll.directive';
@Component({
encapsulation: ViewEncapsulation.None,
providers: [],
selector: 'app-grid-sample',
styleUrls: ['grid-toolbar-pinning-both-sides.component.scss'],
templateUrl: 'grid-toolbar-pinning-both-sides.component.html',
imports: [
NgClass,
IgxGridComponent,
IgxPreventDocumentScrollDirective,
IgxGridToolbarComponent,
IgxGridToolbarActionsComponent,
IgxColumnComponent,
IgxButtonDirective
]
})
export class GridBothSideToolbarPinningSampleComponent implements OnInit {
@ViewChild('grid1', { static: true }) public grid1: IgxGridComponent;
public useDarkTheme: boolean = false;
public data: any[];
public columns: any[];
public pinningConfig: IPinningConfig = { columns: ColumnPinningPosition.End };
public ngOnInit(): void {
this.columns = [
{ field: 'CompanyName', header: 'Company Name', width: 300 },
{ field: 'ContactName', header: 'Contact Name', width: 200, pinned: true, pinningPosition: ColumnPinningPosition.Start },
{ field: 'ContactTitle', header: 'Contact Title', width: 200, pinned: true, pinningPosition: ColumnPinningPosition.End },
{ field: 'Address', header: 'Address', width: 300 },
{ field: 'City', header: 'City', width: 120 },
{ field: 'Region', header: 'Region', width: 120 },
{ field: 'PostalCode', header: 'Postal Code', width: 150 },
{ field: 'Phone', header: 'Phone', width: 150 },
{ field: 'Fax', header: 'Fax', width: 150 }
];
this.data = DATA;
}
public pinLeft() {
this.grid1.selectedColumns().forEach((col: IgxColumnComponent) => {
if (col.pinned) {
col.unpin();
}
col.pin(undefined, ColumnPinningPosition.Start);
});
}
public pinRight() {
this.grid1.selectedColumns().forEach((col: IgxColumnComponent) => {
if (col.pinned) {
col.unpin();
}
col.pin(undefined, ColumnPinningPosition.End);
});
}
public unpinColumn() {
this.grid1.selectedColumns().forEach((col: IgxColumnComponent) => {
col.unpin();
});
}
}