Skip to content

Commit e29ebdd

Browse files
committed
feat(Docs): #2530 Adding ///-comments to IgxTreeGridComponent members.
1 parent 90b4359 commit e29ebdd

File tree

1 file changed

+100
-24
lines changed

1 file changed

+100
-24
lines changed

projects/igniteui-angular/src/lib/grids/tree-grid/tree-grid.component.ts

Lines changed: 100 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import {
2-
ContentChild,
32
ChangeDetectionStrategy,
43
ChangeDetectorRef,
54
Component,
@@ -8,10 +7,6 @@ import {
87
HostBinding,
98
Input,
109
IterableDiffers,
11-
QueryList,
12-
TemplateRef,
13-
ViewChild,
14-
ViewChildren,
1510
ViewContainerRef,
1611
Output,
1712
EventEmitter,
@@ -20,9 +15,6 @@ import {
2015
forwardRef
2116
} from '@angular/core';
2217
import { IgxSelectionAPIService } from '../../core/selection';
23-
import { cloneArray } from '../../core/utils';
24-
import { DisplayDensity } from '../../core/displayDensity';
25-
import { ISortingExpression } from '../../data-operations/sorting-expression.interface';
2618
import { IgxTreeGridAPIService } from './tree-grid-api.service';
2719
import { IgxGridBaseComponent, IgxGridTransaction } from '../grid-base.component';
2820
import { GridBaseAPIService } from '../api.service';
@@ -35,19 +27,19 @@ import { IgxGridNavigationService } from '../grid-navigation.service';
3527
let NEXT_ID = 0;
3628

3729
/**
38-
* **Ignite UI for Angular Grid** -
30+
* **Ignite UI for Angular Tree Grid** -
3931
* [Documentation](https://www.infragistics.com/products/ignite-ui-angular/angular/components/grid.html)
4032
*
41-
* The Ignite UI Grid is used for presenting and manipulating tabular data in the simplest way possible. Once data
42-
* has been bound, it can be manipulated through filtering, sorting & editing operations.
33+
* The Ignite UI Tree Grid displays and manipulates hierarchical data with consistent schema formatted as a table and
34+
* provides features such as sorting, filtering, editing, column pinning, paging, column moving and hiding.
4335
*
4436
* Example:
4537
* ```html
46-
* <igx-grid [data]="employeeData" autoGenerate="false">
38+
* <igx-tree-grid [data]="employeeData" primaryKey="employeeID" foreignKey="PID" autoGenerate="false">
4739
* <igx-column field="first" header="First Name"></igx-column>
4840
* <igx-column field="last" header="Last Name"></igx-column>
4941
* <igx-column field="role" header="Role"></igx-column>
50-
* </igx-grid>
42+
* </igx-tree-grid>
5143
* ```
5244
*/
5345
@Component({
@@ -64,9 +56,9 @@ export class IgxTreeGridComponent extends IgxGridBaseComponent {
6456
/**
6557
* An @Input property that sets the value of the `id` attribute. If not provided it will be automatically generated.
6658
* ```html
67-
* <igx-grid [id]="'igx-grid-1'" [data]="Data" [autoGenerate]="true"></igx-grid>
59+
* <igx-tree-grid [id]="'igx-tree-grid-1'"></igx-tree-grid>
6860
* ```
69-
* @memberof IgxGridComponent
61+
* @memberof IgxTreeGridComponent
7062
*/
7163
@HostBinding('attr.id')
7264
@Input()
@@ -86,45 +78,67 @@ export class IgxTreeGridComponent extends IgxGridBaseComponent {
8678
*/
8779
public flatData: any[];
8880

81+
/**
82+
* Returns an array of the root level `ITreeGridRecord`s.
83+
*/
8984
public rootRecords: ITreeGridRecord[];
9085

86+
/**
87+
* Returns a map of all `ITreeGridRecord`s.
88+
*/
9189
public records: Map<any, ITreeGridRecord> = new Map<any, ITreeGridRecord>();
9290

91+
/**
92+
* Returns an array of processed root `ITreeGridRecord`s.
93+
*/
9394
public processedRootRecords: ITreeGridRecord[];
9495

96+
/**
97+
* Returns a map of all processed `ITreeGridRecord`s.
98+
*/
9599
public processedRecords: Map<any, ITreeGridRecord> = new Map<any, ITreeGridRecord>();
96100

97101
/**
98102
* An @Input property that sets the child data key of the `IgxTreeGridComponent`.
99103
* ```html
100-
* <igx-tree-grid #grid [data]="localData" [showToolbar]="true" [childDataKey]="employees" [autoGenerate]="true"></igx-tree-grid>
104+
* <igx-tree-grid #grid [data]="employeeData" [childDataKey]="employees" [autoGenerate]="true"></igx-tree-grid>
101105
* ```
102-
* @memberof IgxTreeGridRowComponent
106+
* @memberof IgxTreeGridComponent
103107
*/
104108
@Input()
105109
public childDataKey;
106110

107111
/**
108112
* An @Input property that sets the foreign key of the `IgxTreeGridComponent`.
109113
* ```html
110-
* <igx-tree-grid #grid [data]="localData" [primaryKey]="employeeID" [foreignKey]="parentID" [autoGenerate]="true"></igx-tree-grid>
114+
* <igx-tree-grid #grid [data]="employeeData" [primaryKey]="employeeID" [foreignKey]="parentID" [autoGenerate]="true"></igx-tree-grid>
111115
* ```
112-
* @memberof IgxTreeGridRowComponent
116+
* @memberof IgxTreeGridComponent
113117
*/
114118
@Input()
115119
public foreignKey;
116120

121+
/**
122+
* An @Input property indicating whether child records should be deleted when their parent gets deleted.
123+
* By default it is set to true and deletes all children along with the parent.
124+
* ```html
125+
* <igx-tree-grid [data]="employeeData" [primaryKey]="employeeID" [foreignKey]="parentID" cascadeOnDelete="false" [autoGenerate]="true">
126+
* </igx-tree-grid>
127+
* ```
128+
* @memberof IgxTreeGridComponent
129+
*/
117130
@Input()
118131
public cascadeOnDelete = true;
119132

120133
private _expansionDepth = Infinity;
121134

122135
/**
123-
* An @Input property that sets the count of levels to expand by default in the `IgxTreeGridComponent`.
136+
* An @Input property that sets the count of levels to be expanded in the `IgxTreeGridComponent`. By default it is
137+
* set to `Infinity` which means all levels would be expanded.
124138
* ```html
125-
* <igx-tree-grid #grid [data]="localData" [childDataKey]="employees" expandedLevels="1" [autoGenerate]="true"></iigx-tree-grid>
139+
* <igx-tree-grid #grid [data]="employeeData" [childDataKey]="employees" expansionDepth="1" [autoGenerate]="true"></igx-tree-grid>
126140
* ```
127-
* @memberof IgxTreeGridRowComponent
141+
* @memberof IgxTreeGridComponent
128142
*/
129143
@Input()
130144
public get expansionDepth(): number {
@@ -138,6 +152,13 @@ export class IgxTreeGridComponent extends IgxGridBaseComponent {
138152

139153
private _expansionStates: Map<any, boolean> = new Map<any, boolean>();
140154

155+
/**
156+
* Returns a list of key-value pairs [row ID, expansion state]. Includes only states that differ from the default one.
157+
* ```typescript
158+
* const expansionStates = this.grid.expansionStates;
159+
* ```
160+
* @memberof IgxTreeGridComponent
161+
*/
141162
@Input()
142163
public get expansionStates() {
143164
return this._expansionStates;
@@ -148,6 +169,25 @@ export class IgxTreeGridComponent extends IgxGridBaseComponent {
148169
this.cdr.detectChanges();
149170
}
150171

172+
/**
173+
* Emitted when the expanded state of a row gets changed.
174+
* ```typescript
175+
* rowToggle(event: IRowToggleEventArgs){
176+
* // the id of the row
177+
* const rowID = event.rowID;
178+
* // the new expansion state
179+
* const newExpandedState = event.expanded;
180+
* // the original event that triggered onRowToggle
181+
* const originalEvent = event.event;
182+
* // whether the event should be cancelled
183+
* event.cancel = true;
184+
* }
185+
* ```
186+
* ```html
187+
* <igx-tree-grid [data]="employeeData" (onRowToggle)="rowToggle($event)" [autoGenerate]="true"></igx-tree-grid>
188+
* ```
189+
* @memberof IgxTreeGridComponent
190+
*/
151191
@Output()
152192
public onRowToggle = new EventEmitter<IRowToggleEventArgs>();
153193

@@ -170,11 +210,12 @@ export class IgxTreeGridComponent extends IgxGridBaseComponent {
170210
}
171211

172212
/**
173-
* Returns if the `IgxGridComponent` has summarized columns.
213+
* @hidden
214+
* Returns if the `IgxTreeGridComponent` has summarized columns.
174215
* ```typescript
175216
* const summarizedGrid = this.grid.hasSummarizedColumns;
176217
* ```
177-
* @memberof IgxGridComponent
218+
* @memberof IgxTreeGridComponent
178219
*/
179220
get hasSummarizedColumns(): boolean {
180221
return false;
@@ -191,28 +232,63 @@ export class IgxTreeGridComponent extends IgxGridBaseComponent {
191232
return mapCloned;
192233
}
193234

235+
/**
236+
* Expands the `IgxTreeGridRowComponent` with the specified rowID.
237+
* @param rowID The identifier of the row to be expanded.
238+
*/
194239
public expandRow(rowID: any) {
195240
this._gridAPI.expand_row(this.id, rowID);
196241
}
197242

243+
/**
244+
* Collapses the `IgxTreeGridRowComponent` with the specified rowID.
245+
* @param rowID The identifier of the row to be collapsed.
246+
*/
198247
public collapseRow(rowID: any) {
199248
this._gridAPI.collapse_row(this.id, rowID);
200249
}
201250

251+
/**
252+
* Toggles the expansion state of the `IgxTreeGridRowComponent` with the specified rowID.
253+
* @param rowID The identifier of the row to be toggled.
254+
*/
202255
public toggleRow(rowID: any) {
203256
this._gridAPI.toggle_row_expansion(this.id, rowID);
204257
}
205258

259+
/**
260+
* Expands all rows.
261+
*/
206262
public expandAll() {
207263
this._expansionDepth = Infinity;
208264
this.expansionStates = new Map<any, boolean>();
209265
}
210266

267+
/**
268+
* Collapses all rows.
269+
*/
211270
public collapseAll() {
212271
this._expansionDepth = 0;
213272
this.expansionStates = new Map<any, boolean>();
214273
}
215274

275+
/**
276+
* Creates a new `IgxTreeGridRowComponent` with the given data. If a parentRowID is not specified, the newly created
277+
* row would be added at the root level. Otherwise, it would be added as a child of the row whose primaryKey matches
278+
* the specified parentRowID. If the parentRowID does not exist, an error would be thrown.
279+
* ```typescript
280+
* const record = {
281+
* ID: this.grid.data[this.grid1.data.length - 1].ID + 1,
282+
* parentID: null,
283+
* Name: this.newRecord
284+
* };
285+
* this.grid.addRow(record); // Adds a new row at level 0.
286+
* this.grid.addRow(record, 1); // Adds a new child row to the row with ID=1.
287+
* ```
288+
* @param data
289+
* @param parentRowID
290+
* @memberof IgxTreeGridComponent
291+
*/
216292
public addRow(data: any, parentRowID?: any) {
217293
if (parentRowID) {
218294
const parentRecord = this.records.get(parentRowID);

0 commit comments

Comments
 (0)