|
| 1 | +import { |
| 2 | + ContentChild, |
| 3 | + ChangeDetectionStrategy, |
| 4 | + ChangeDetectorRef, |
| 5 | + Component, |
| 6 | + ComponentFactoryResolver, |
| 7 | + ElementRef, |
| 8 | + HostBinding, |
| 9 | + Input, |
| 10 | + IterableDiffers, |
| 11 | + QueryList, |
| 12 | + TemplateRef, |
| 13 | + ViewChild, |
| 14 | + ViewChildren, |
| 15 | + ViewContainerRef |
| 16 | +} from '@angular/core'; |
| 17 | +import { IgxSelectionAPIService } from '../core/selection'; |
| 18 | +import { cloneArray, DisplayDensity } from '../core/utils'; |
| 19 | +import { ISortingExpression } from '../data-operations/sorting-expression.interface'; |
| 20 | +import { IgxTreeGridAPIService } from './tree-grid-api.service'; |
| 21 | +import { IgxGridBaseComponent } from '../grid-common/grid-base.component'; |
| 22 | + |
| 23 | +import { IGridBaseComponent } from '../grid-common/common/grid-interfaces'; |
| 24 | +import { IGridAPIService } from '../grid-common/api.service'; |
| 25 | + |
| 26 | +let NEXT_ID = 0; |
| 27 | + |
| 28 | +/** |
| 29 | + * **Ignite UI for Angular Grid** - |
| 30 | + * [Documentation](https://www.infragistics.com/products/ignite-ui-angular/angular/components/grid.html) |
| 31 | + * |
| 32 | + * The Ignite UI Grid is used for presenting and manipulating tabular data in the simplest way possible. Once data |
| 33 | + * has been bound, it can be manipulated through filtering, sorting & editing operations. |
| 34 | + * |
| 35 | + * Example: |
| 36 | + * ```html |
| 37 | + * <igx-grid [data]="employeeData" autoGenerate="false"> |
| 38 | + * <igx-column field="first" header="First Name"></igx-column> |
| 39 | + * <igx-column field="last" header="Last Name"></igx-column> |
| 40 | + * <igx-column field="role" header="Role"></igx-column> |
| 41 | + * </igx-grid> |
| 42 | + * ``` |
| 43 | + */ |
| 44 | +@Component({ |
| 45 | + changeDetection: ChangeDetectionStrategy.OnPush, |
| 46 | + preserveWhitespaces: false, |
| 47 | + selector: 'igx-tree-grid', |
| 48 | + templateUrl: './grid.component.html' |
| 49 | +}) |
| 50 | +export class IgxTreeGridComponent extends IgxGridBaseComponent { |
| 51 | + private _id = `igx-tree-grid-${NEXT_ID++}`; |
| 52 | + |
| 53 | + /** |
| 54 | + * An @Input property that sets the value of the `id` attribute. If not provided it will be automatically generated. |
| 55 | + * ```html |
| 56 | + * <igx-grid [id]="'igx-grid-1'" [data]="Data" [autoGenerate]="true"></igx-grid> |
| 57 | + * ``` |
| 58 | + * @memberof IgxGridComponent |
| 59 | + */ |
| 60 | + @HostBinding('attr.id') |
| 61 | + @Input() |
| 62 | + public get id(): string { |
| 63 | + return this._id; |
| 64 | + } |
| 65 | + public set id(value: string) { |
| 66 | + if (this._id !== value) { |
| 67 | + const oldId = this._id; |
| 68 | + this._id = value; |
| 69 | + this.gridAPI.reset(oldId, this._id); |
| 70 | + } |
| 71 | + } |
| 72 | + |
| 73 | + private gridAPI: IgxTreeGridAPIService; |
| 74 | + |
| 75 | + constructor( |
| 76 | + gridAPI: IGridAPIService<IGridBaseComponent>, |
| 77 | + selection: IgxSelectionAPIService, |
| 78 | + elementRef: ElementRef, |
| 79 | + cdr: ChangeDetectorRef, |
| 80 | + resolver: ComponentFactoryResolver, |
| 81 | + differs: IterableDiffers, |
| 82 | + viewRef: ViewContainerRef) { |
| 83 | + super(gridAPI, selection, elementRef, cdr, resolver, differs, viewRef); |
| 84 | + this.gridAPI = <IgxTreeGridAPIService>gridAPI; |
| 85 | + } |
| 86 | + |
| 87 | + /** |
| 88 | + * @hidden |
| 89 | + */ |
| 90 | + public getContext(rowData): any { |
| 91 | + return { |
| 92 | + $implicit: rowData, |
| 93 | + // templateID: this.isGroupByRecord(rowData) ? 'groupRow' : 'dataRow' |
| 94 | + }; |
| 95 | + } |
| 96 | +} |
0 commit comments