Skip to content

Commit 1476867

Browse files
committed
fix(row-adding): implementing changes from review comments.
1 parent c2e5c74 commit 1476867

File tree

3 files changed

+40
-17
lines changed

3 files changed

+40
-17
lines changed

CHANGELOG.md

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,18 @@ All notable changes for each version of this project will be documented in this
66

77
### New Features
88
- `igxGrid`, `igxHierarchicalGrid`, `igxTreeGrid`
9-
- Added two public methods that spawn the add row UI for an arbitrary record in the current data view. One that accepts a rowID to use as the row the UI spawns under and the other specifying the index at which to spawn it. Please, note that the new record is still added at the end of the data view, after the end-user submits it.
10-
```typescript
11-
this.grid.beginAddRowById('ALFKI'); // spawns the add row UI under the row with PK 'ALFKI'
12-
this.grid.beginAddRowById('ALFKI', true); // spawns the add row UI to add a child for the row with PK 'ALFKI'
13-
this.grid.beginAddRowById(null); // spawns the add row UI as the first record
14-
this.grid.beginAddRowByIndex(10); // spawns the add row UI at index 10
15-
this.grid.beginAddRowByIndex(10, true); // spawns the add row UI to add a child for the row at index 9
16-
this.grid.beginAddRowByIndex(0); // spawns the add row UI as the first record
17-
```
9+
- Added two public methods that spawn the add row UI for an arbitrary record in the current data view. One that accepts a rowID to use as the row the UI spawns under and the other accepting an index that has a distinct implementation for `IgxTreeGrid`. Please, refer to the official documentation for more information:[Grid Row Adding](https://www.infragistics.com/products/ignite-ui-angular/angular/components/grid/row-adding) and [Tree Grid Row Adding](https://www.infragistics.com/products/ignite-ui-angular/angular/components/treegrid/row-adding).
10+
11+
_Note:_ That the new record is still added at the end of the data view, after the end-user submits it.
12+
```typescript
13+
this.grid.beginAddRowById('ALFKI'); // spawns the add row UI under the row with PK 'ALFKI'
14+
this.grid.beginAddRowById(null); // spawns the add row UI as the first record
15+
this.grid.beginAddRowByIndex(10); // spawns the add row UI at index 10
16+
this.grid.beginAddRowByIndex(0); // spawns the add row UI as the first record
17+
this.treeGrid.beginAddRowById('ALFKI', true); // spawns the add row UI to add a child for the row with PK 'ALFKI'
18+
this.treeGrid.beginAddRowByIndex(10, true); // spawns the add row UI to add a child for the row at index 10
19+
this.treeGrid.beginAddRowByIndex(null); // spawns the add row UI as the first record
20+
```
1821

1922
## 12.1.3
2023

projects/igniteui-angular/src/lib/grids/grid-base.directive.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6029,22 +6029,17 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
60296029
*
60306030
* @remarks
60316031
* Accepted values for index are integers from 0 to this.grid.dataView.length
6032-
* @remarks
6033-
* When adding the row as a child, the parent row is the one at the previous index. You cannot add a child at index 0.
60346032
* @example
60356033
* ```typescript
6036-
* this.grid.beginAddRowByIndex(10);
6037-
* this.grid.beginAddRowByIndex(10, true);
60386034
* this.grid.beginAddRowByIndex(0);
60396035
* ```
60406036
* @param index - The index to spawn the UI at. Accepts integers from 0 to this.grid.dataView.length
6041-
* @param asChild - Whether the record should be added as a child. Only applicable to igxTreeGrid.
60426037
*/
6043-
public beginAddRowByIndex(index: number, asChild?: boolean): void {
6038+
public beginAddRowByIndex(index: number): void {
60446039
if (index === 0) {
6045-
return this.beginAddRowById(null, asChild);
6040+
return this.beginAddRowById(null);
60466041
}
6047-
return this.beginAddRowById(this.gridAPI.get_rec_id_by_index(index - 1, this.dataView), asChild);
6042+
return this.beginAddRowById(this.gridAPI.get_rec_id_by_index(index - 1, this.dataView));
60486043
}
60496044

60506045
protected beginAddRowForIndex(index: number, asChild: boolean = false) {

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,31 @@ export class IgxTreeGridComponent extends IgxGridBaseDirective implements GridTy
605605
this.notifyChanges();
606606
}
607607

608+
/**
609+
* Enters add mode by spawning the UI with the context of the specified row by index.
610+
*
611+
* @remarks
612+
* Accepted values for index are integers from 0 to this.grid.dataView.length
613+
* @remarks
614+
* When adding the row as a child, the parent row is the specified row.
615+
* @remarks
616+
* To spawn the UI on top, call the function with index = null or a negative number. In this case trying to add this row as a child will result in error.
617+
* @example
618+
* ```typescript
619+
* this.grid.beginAddRowByIndex(10);
620+
* this.grid.beginAddRowByIndex(10, true);
621+
* this.grid.beginAddRowByIndex(null);
622+
* ```
623+
* @param index - The index to spawn the UI at. Accepts integers from 0 to this.grid.dataView.length
624+
* @param asChild - Whether the record should be added as a child. Only applicable to igxTreeGrid.
625+
*/
626+
public beginAddRowByIndex(index: number, asChild?: boolean): void {
627+
if (index === null || index < 0) {
628+
return this.beginAddRowById(null, asChild);
629+
}
630+
return this.beginAddRowById(this.gridAPI.get_rec_id_by_index(index, this.dataView), asChild);
631+
}
632+
608633
/**
609634
* @hidden
610635
*/

0 commit comments

Comments
 (0)