Skip to content

Commit 47a43d7

Browse files
authored
Merge pull request #9170 from IgniteUI/mdragnev/addrow-templating
Add igxRowAddText directive for templating add row banner
2 parents 3b2709b + d1a6ceb commit 47a43d7

File tree

9 files changed

+51
-8
lines changed

9 files changed

+51
-8
lines changed

CHANGELOG.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,15 @@ All notable changes for each version of this project will be documented in this
77
### New Features
88
- `IgxForOf`, `IgxGrid`, `IgxTreeGrid`, `IgxHierarchicalGrid`
99
- **Behavioral Change** - Virtual containers now scroll smoothly when using the mouse wheel(s) to scroll them horizontally or vertically. This behavior more closely resembles the scrolling behavior of non-virtualized containers in most modern browsers.
10-
11-
10+
- `IgxGrid`, `IgxTreeGrid`, `IgxHierarchicalGrid`
11+
- The `IgxRowAddTextDirective` allows to customize the text of the row adding overlay.
12+
```html
13+
<igx-grid [rowEditable]="true">
14+
<ng-template igxRowAddText>
15+
Adding Row
16+
</ng-template>
17+
</igx-grid>
18+
```
1219
### Themes:
1320
- Breaking Changes:
1421
- `IgxButton` theme has been simplified. The number of theme params (`igx-button-theme`) has been reduced significantly and no longer includes prefixed parameters (`flat-*`, `raised-*`, etc.). See the migration guide to update existing button themes. Updates performed with `ng update` will migrate existing button themes but some additional tweaking may be required to account for the abscense of prefixed params.

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ import {
6666
import { IFilteringOperation } from '../data-operations/filtering-condition';
6767
import { Transaction, TransactionType, TransactionService, State } from '../services/public_api';
6868
import {
69+
IgxRowAddTextDirective,
6970
IgxRowEditTemplateDirective,
7071
IgxRowEditTabStopDirective,
7172
IgxRowEditTextDirective,
@@ -1128,12 +1129,19 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
11281129
*/
11291130
@ContentChild(IgxRowEditTemplateDirective, { read: TemplateRef })
11301131
public rowEditCustom: TemplateRef<any>;
1132+
11311133
/**
11321134
* @hidden @internal
11331135
*/
11341136
@ContentChild(IgxRowEditTextDirective, { read: TemplateRef })
11351137
public rowEditText: TemplateRef<any>;
11361138

1139+
/**
1140+
* @hidden @internal
1141+
*/
1142+
@ContentChild(IgxRowAddTextDirective, { read: TemplateRef })
1143+
public rowAddText: TemplateRef<any>;
1144+
11371145
/**
11381146
* @hidden @internal
11391147
*/

projects/igniteui-angular/src/lib/grids/grid-common.module.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
import { IgxGridTransaction } from './grid-base.directive';
88
import { IgxBaseTransactionService } from '../services/transaction/base-transaction';
99
import {
10+
IgxRowAddTextDirective,
1011
IgxRowEditTemplateDirective,
1112
IgxRowEditActionsDirective,
1213
IgxRowEditTextDirective,
@@ -42,6 +43,7 @@ import {
4243
declarations: [
4344
IgxRowDirective,
4445
IgxGridCellComponent,
46+
IgxRowAddTextDirective,
4547
IgxRowEditTemplateDirective,
4648
IgxRowEditActionsDirective,
4749
IgxRowEditTextDirective,
@@ -60,6 +62,7 @@ import {
6062
],
6163
exports: [
6264
IgxGridCellComponent,
65+
IgxRowAddTextDirective,
6366
IgxRowEditTemplateDirective,
6467
IgxRowEditActionsDirective,
6568
IgxRowEditTextDirective,

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ export class IgxRowEditTemplateDirective { }
1313
})
1414
export class IgxRowEditTextDirective { }
1515

16+
/** @hidden @internal */
17+
@Directive({
18+
selector: '[igxRowAddText]'
19+
})
20+
export class IgxRowAddTextDirective { }
21+
1622
/** @hidden @internal */
1723
@Directive({
1824
selector: '[igxRowEditActions]'

projects/igniteui-angular/src/lib/grids/grid/grid-add-row.spec.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,19 @@ describe('IgxGrid - Row Adding #grid', () => {
310310

311311
expect(grid.addRowSnackbar.isVisible).toBe(false);
312312
});
313+
314+
it('Should set templated banner text when adding row', () => {
315+
const rows = grid.rowList.toArray();
316+
rows[0].beginAddRow();
317+
fixture.detectChanges();
318+
319+
endTransition();
320+
321+
const addRow = grid.getRowByIndex(1);
322+
expect(addRow.addRow).toBeTrue();
323+
324+
expect(GridFunctions.getRowEditingBannerText(fixture)).toEqual('Adding Row');
325+
});
313326
});
314327

315328
describe('Add row events tests:', () => {

projects/igniteui-angular/src/lib/grids/grid/grid.component.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,10 +315,11 @@
315315
</ng-template>
316316

317317
<ng-template #defaultRowEditTemplate>
318-
<div class="igx-banner__message" *ngIf="!this.crudService.row?.isAddRow">
318+
<div class="igx-banner__message">
319319
<span class="igx-banner__text">
320320
<ng-container
321-
*ngTemplateOutlet="rowEditText ? rowEditText : defaultRowEditText; context: { $implicit: rowChangesCount }">
321+
*ngTemplateOutlet="this.crudService.row?.isAddRow ? rowAddText : rowEditText ? rowEditText : defaultRowEditText;
322+
context: { $implicit: !this.crudService.row?.isAddRow ? rowChangesCount : null }">
322323
</ng-container>
323324
</span>
324325
</div>

projects/igniteui-angular/src/lib/grids/hierarchical-grid/hierarchical-grid.component.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,10 +268,11 @@
268268
<button igxButton igxRowEditTabStop (click)="endRowEdit(true, $event)">Done</button>
269269
</ng-template>
270270
<ng-template #defaultRowEditTemplate>
271-
<div class="igx-banner__message" *ngIf="!this.crudService.row?.isAddRow">
271+
<div class="igx-banner__message">
272272
<span class="igx-banner__text">
273273
<ng-container
274-
*ngTemplateOutlet="rowEditText ? rowEditText : defaultRowEditText; context: { $implicit: rowChangesCount }">
274+
*ngTemplateOutlet="this.crudService.row?.isAddRow ? rowAddText : rowEditText ? rowEditText : defaultRowEditText;
275+
context: { $implicit: !this.crudService.row?.isAddRow ? rowChangesCount : null }">
275276
</ng-container>
276277
</span>
277278
</div>

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,10 +230,11 @@
230230
</ng-template>
231231

232232
<ng-template #defaultRowEditTemplate>
233-
<div class="igx-banner__message" *ngIf="!this.crudService.row?.isAddRow">
233+
<div class="igx-banner__message">
234234
<span class="igx-banner__text">
235235
<ng-container
236-
*ngTemplateOutlet="rowEditText ? rowEditText : defaultRowEditText; context: { $implicit: rowChangesCount }">
236+
*ngTemplateOutlet="this.crudService.row?.isAddRow ? rowAddText : rowEditText ? rowEditText : defaultRowEditText;
237+
context: { $implicit: !this.crudService.row?.isAddRow ? rowChangesCount : null }">
237238
</ng-container>
238239
</span>
239240
</div>

projects/igniteui-angular/src/lib/test-utils/grid-samples.spec.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2311,6 +2311,9 @@ export class MRLTestComponent {
23112311
<igx-action-strip #actionStrip>
23122312
<igx-grid-editing-actions [addRow]='true'></igx-grid-editing-actions>
23132313
</igx-action-strip>
2314+
<ng-template igxRowAddText>
2315+
Adding Row
2316+
</ng-template>
23142317
</igx-grid>
23152318
`
23162319
})

0 commit comments

Comments
 (0)