Skip to content

Commit b8cf9d2

Browse files
committed
docs(tree-grid): adding some more API comments #2530
1 parent 20fba6e commit b8cf9d2

File tree

2 files changed

+79
-13
lines changed

2 files changed

+79
-13
lines changed

Diff for: projects/igniteui-angular/src/lib/grids/tree-grid/tree-grid-row.component.ts

+21-3
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,19 @@ export class IgxTreeGridRowComponent extends IgxRowComponent<IgxTreeGridComponen
1818
* The rendered cells in the row component.
1919
*
2020
* ```typescript
21-
* // get the cells of the third selected row
22-
* let selectedRowCells = this.grid.selectedRows[2].cells;
21+
* const row = this.grid.getRowByKey(1);
22+
* const cells = row.cells;
2323
* ```
2424
*/
2525
@ViewChildren('treeCell')
2626
public cells: QueryList<any>;
2727

2828
/**
29-
* The flat data row passed to the tree grid row component.
29+
* The `ITreeGridRecord` passed to the row component.
3030
*
3131
* ```typescript
32+
* const row = this.grid.getRowByKey(1) as IgxTreeGridRowComponent;
33+
* const treeRow = row.treeRow;
3234
* ```
3335
*/
3436
@Input()
@@ -42,11 +44,27 @@ export class IgxTreeGridRowComponent extends IgxRowComponent<IgxTreeGridComponen
4244
}
4345
}
4446

47+
/**
48+
* Returns a value indicating whether the row component is expanded.
49+
*
50+
* ```typescript
51+
* const row = this.grid.getRowByKey(1) as IgxTreeGridRowComponent;
52+
* const expanded = row.expanded;
53+
* ```
54+
*/
4555
@HostBinding('attr.aria-expanded')
4656
get expanded(): boolean {
4757
return this._treeRow.expanded;
4858
}
4959

60+
/**
61+
* Sets a value indicating whether the row component is expanded.
62+
*
63+
* ```typescript
64+
* const row = this.grid.getRowByKey(1) as IgxTreeGridRowComponent;
65+
* row.expanded = true;
66+
* ```
67+
*/
5068
set expanded(value: boolean) {
5169
(this.gridAPI as IgxTreeGridAPIService).trigger_row_expansion_toggle(this.gridID, this._treeRow, value);
5270
}

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

+58-10
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import { IRowToggleEventArgs } from './tree-grid.interfaces';
2323
import { TransactionService } from '../../services/transaction/transaction';
2424
import { DOCUMENT } from '@angular/common';
2525
import { IgxGridNavigationService } from '../grid-navigation.service';
26+
import { IgxTreeGridRowComponent } from './tree-grid-row.component';
2627

2728
let NEXT_ID = 0;
2829

@@ -79,23 +80,43 @@ export class IgxTreeGridComponent extends IgxGridBaseComponent {
7980
public flatData: any[];
8081

8182
/**
82-
* Returns an array of the root level `ITreeGridRecord`s.
83-
*/
83+
* Returns an array of the root level `ITreeGridRecord`s.
84+
* ```typescript
85+
* // gets the root record with index=2
86+
* const states = this.grid.rootRecords[2];
87+
* ```
88+
* @memberof IgxTreeGridComponent
89+
*/
8490
public rootRecords: ITreeGridRecord[];
8591

8692
/**
87-
* Returns a map of all `ITreeGridRecord`s.
88-
*/
93+
* Returns a map of all `ITreeGridRecord`s.
94+
* ```typescript
95+
* // gets the record with primaryKey=2
96+
* const states = this.grid.records.get(2);
97+
* ```
98+
* @memberof IgxTreeGridComponent
99+
*/
89100
public records: Map<any, ITreeGridRecord> = new Map<any, ITreeGridRecord>();
90101

91102
/**
92-
* Returns an array of processed root `ITreeGridRecord`s.
93-
*/
103+
* Returns an array of processed (filtered and sorted) root `ITreeGridRecord`s.
104+
* ```typescript
105+
* // gets the processed root record with index=2
106+
* const states = this.grid.processedRootRecords[2];
107+
* ```
108+
* @memberof IgxTreeGridComponent
109+
*/
94110
public processedRootRecords: ITreeGridRecord[];
95111

96112
/**
97-
* Returns a map of all processed `ITreeGridRecord`s.
98-
*/
113+
* Returns a map of all processed (filtered and sorted) `ITreeGridRecord`s.
114+
* ```typescript
115+
* // gets the processed record with primaryKey=2
116+
* const states = this.grid.processedRecords.get(2);
117+
* ```
118+
* @memberof IgxTreeGridComponent
119+
*/
99120
public processedRecords: Map<any, ITreeGridRecord> = new Map<any, ITreeGridRecord>();
100121

101122
/**
@@ -164,6 +185,15 @@ export class IgxTreeGridComponent extends IgxGridBaseComponent {
164185
return this._expansionStates;
165186
}
166187

188+
/**
189+
* Sets a list of key-value pairs [row ID, expansion state].
190+
* ```typescript
191+
* const states = new Map<any, boolean>();
192+
* states.set(1, true);
193+
* this.grid.expansionStates = states;
194+
* ```
195+
* @memberof IgxTreeGridComponent
196+
*/
167197
public set expansionStates(value) {
168198
this._expansionStates = this.cloneMap(value);
169199
this.cdr.detectChanges();
@@ -235,6 +265,10 @@ export class IgxTreeGridComponent extends IgxGridBaseComponent {
235265
/**
236266
* Expands the `IgxTreeGridRowComponent` with the specified rowID.
237267
* @param rowID The identifier of the row to be expanded.
268+
* ```typescript
269+
* this.grid.expandRow(2);
270+
* ```
271+
* @memberof IgxTreeGridComponent
238272
*/
239273
public expandRow(rowID: any) {
240274
this._gridAPI.expand_row(this.id, rowID);
@@ -243,6 +277,10 @@ export class IgxTreeGridComponent extends IgxGridBaseComponent {
243277
/**
244278
* Collapses the `IgxTreeGridRowComponent` with the specified rowID.
245279
* @param rowID The identifier of the row to be collapsed.
280+
* ```typescript
281+
* this.grid.collapseRow(2);
282+
* ```
283+
* @memberof IgxTreeGridComponent
246284
*/
247285
public collapseRow(rowID: any) {
248286
this._gridAPI.collapse_row(this.id, rowID);
@@ -251,13 +289,21 @@ export class IgxTreeGridComponent extends IgxGridBaseComponent {
251289
/**
252290
* Toggles the expansion state of the `IgxTreeGridRowComponent` with the specified rowID.
253291
* @param rowID The identifier of the row to be toggled.
292+
* ```typescript
293+
* this.grid.toggleRow(2);
294+
* ```
295+
* @memberof IgxTreeGridComponent
254296
*/
255297
public toggleRow(rowID: any) {
256298
this._gridAPI.toggle_row_expansion(this.id, rowID);
257299
}
258300

259301
/**
260302
* Expands all rows.
303+
* ```typescript
304+
* this.grid.expandAll();
305+
* ```
306+
* @memberof IgxTreeGridComponent
261307
*/
262308
public expandAll() {
263309
this._expansionDepth = Infinity;
@@ -266,6 +312,10 @@ export class IgxTreeGridComponent extends IgxGridBaseComponent {
266312

267313
/**
268314
* Collapses all rows.
315+
* ```typescript
316+
* this.grid.collapseAll();
317+
* ```
318+
* @memberof IgxTreeGridComponent
269319
*/
270320
public collapseAll() {
271321
this._expansionDepth = 0;
@@ -279,10 +329,8 @@ export class IgxTreeGridComponent extends IgxGridBaseComponent {
279329
* ```typescript
280330
* const record = {
281331
* ID: this.grid.data[this.grid1.data.length - 1].ID + 1,
282-
* parentID: null,
283332
* Name: this.newRecord
284333
* };
285-
* this.grid.addRow(record); // Adds a new row at level 0.
286334
* this.grid.addRow(record, 1); // Adds a new child row to the row with ID=1.
287335
* ```
288336
* @param data

0 commit comments

Comments
 (0)