Skip to content

Commit 70b1360

Browse files
committed
Merge branch '13.0.x' of https://github.com/IgniteUI/igniteui-angular into rkaraivanov/column-moving-grid-prop
2 parents e00ecea + 241667f commit 70b1360

21 files changed

+315
-75
lines changed

CHANGELOG.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,24 @@
22

33
All notable changes for each version of this project will be documented in this file.
44

5+
## 13.0.1
6+
7+
### New Features
8+
- Add `igxSummary` directive in order to re-template the default summary cell layout.
9+
- Expose `summaryTemplate` input in order to bind the column summary template through API.
10+
- Expose `summaryRowHeight` property which overrides the default hight of the summary row.
11+
- Code example below:
12+
13+
```html
14+
<igx-column ... [hasSummary]="true">
15+
<ng-template igxSummary let-summaryResult>
16+
<span> My custom summary template</span>
17+
<span>{{ summaryResult[0].label }} - {{ summaryResult[0].summaryResult }}</span>
18+
</ng-template>
19+
</igx-column>
20+
```
21+
- Please, refer to the [Summaries](https://www.infragistics.com/products/ignite-ui-angular/angular/components/grid/summaries#summary-template) topic for more information.
22+
523
## 13.0.0
624

725
### New Features

projects/igniteui-angular/src/lib/grids/columns/column.component.ts

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ import {
4343
IgxCellHeaderTemplateDirective,
4444
IgxCellEditorTemplateDirective,
4545
IgxCollapsibleIndicatorTemplateDirective,
46-
IgxFilterCellTemplateDirective
46+
IgxFilterCellTemplateDirective,
47+
IgxSummaryTemplateDirective
4748
} from './templates.directive';
4849
import { MRLResizeColumnInfo, MRLColumnSizeInfo, IColumnPipeArgs } from './interfaces';
4950
import { DropPosition } from '../moving/moving.service';
@@ -835,6 +836,11 @@ export class IgxColumnComponent implements AfterContentInit, OnDestroy, ColumnTy
835836
*/
836837
@ContentChild(IgxFilterCellTemplateDirective, { read: IgxFilterCellTemplateDirective })
837838
public filterCellTemplateDirective: IgxFilterCellTemplateDirective;
839+
/**
840+
* @hidden
841+
*/
842+
@ContentChild(IgxSummaryTemplateDirective, { read: IgxSummaryTemplateDirective })
843+
protected summaryTemplateDirective: IgxSummaryTemplateDirective;
838844
/**
839845
* @hidden
840846
*/
@@ -855,7 +861,6 @@ export class IgxColumnComponent implements AfterContentInit, OnDestroy, ColumnTy
855861
*/
856862
@ContentChild(IgxCollapsibleIndicatorTemplateDirective, { read: IgxCollapsibleIndicatorTemplateDirective, static: false })
857863
protected collapseIndicatorTemplate: IgxCollapsibleIndicatorTemplateDirective;
858-
859864
/**
860865
* @hidden
861866
*/
@@ -1111,6 +1116,39 @@ export class IgxColumnComponent implements AfterContentInit, OnDestroy, ColumnTy
11111116
return '80';
11121117
}
11131118
}
1119+
/**
1120+
* Returns a reference to the `summaryTemplate`.
1121+
* ```typescript
1122+
* let summaryTemplate = this.column.summaryTemplate;
1123+
* ```
1124+
*
1125+
* @memberof IgxColumnComponent
1126+
*/
1127+
@notifyChanges()
1128+
@WatchColumnChanges()
1129+
@Input()
1130+
public get summaryTemplate(): TemplateRef<any> {
1131+
return this._summaryTemplate;
1132+
}
1133+
/**
1134+
* Sets the summary template.
1135+
* ```html
1136+
* <ng-template #summaryTemplate igxSummary let-summaryResults>
1137+
* <p>{{ summaryResults[0].label }}: {{ summaryResults[0].summaryResult }}</p>
1138+
* <p>{{ summaryResults[1].label }}: {{ summaryResults[1].summaryResult }}</p>
1139+
* </ng-template>
1140+
* ```
1141+
* ```typescript
1142+
* @ViewChild("'summaryTemplate'", {read: TemplateRef })
1143+
* public summaryTemplate: TemplateRef<any>;
1144+
* this.column.summaryTemplate = this.summaryTemplate;
1145+
* ```
1146+
*
1147+
* @memberof IgxColumnComponent
1148+
*/
1149+
public set summaryTemplate(template: TemplateRef<any>) {
1150+
this._summaryTemplate = template;
1151+
}
11141152
/**
11151153
* Returns a reference to the `bodyTemplate`.
11161154
* ```typescript
@@ -1567,6 +1605,10 @@ export class IgxColumnComponent implements AfterContentInit, OnDestroy, ColumnTy
15671605
* @hidden
15681606
*/
15691607
protected _headerTemplate: TemplateRef<any>;
1608+
/**
1609+
* @hidden
1610+
*/
1611+
protected _summaryTemplate: TemplateRef<any>;
15701612
/**
15711613
* @hidden
15721614
*/
@@ -1674,6 +1716,9 @@ export class IgxColumnComponent implements AfterContentInit, OnDestroy, ColumnTy
16741716
* @hidden
16751717
*/
16761718
public ngAfterContentInit(): void {
1719+
if (this.summaryTemplateDirective) {
1720+
this._summaryTemplate = this.summaryTemplateDirective.template;
1721+
}
16771722
if (this.cellTemplate) {
16781723
this._bodyTemplate = this.cellTemplate.template;
16791724
}

projects/igniteui-angular/src/lib/grids/columns/column.module.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@ import {
88
IgxCellHeaderTemplateDirective,
99
IgxCellTemplateDirective,
1010
IgxCollapsibleIndicatorTemplateDirective,
11-
IgxFilterCellTemplateDirective
11+
IgxFilterCellTemplateDirective,
12+
IgxSummaryTemplateDirective
1213
} from './templates.directive';
1314

14-
1515
@NgModule({
1616
declarations: [
1717
IgxFilterCellTemplateDirective,
18+
IgxSummaryTemplateDirective,
1819
IgxCellTemplateDirective,
1920
IgxCellHeaderTemplateDirective,
2021
IgxCellFooterTemplateDirective,
@@ -31,6 +32,7 @@ import {
3132
],
3233
exports: [
3334
IgxFilterCellTemplateDirective,
35+
IgxSummaryTemplateDirective,
3436
IgxCellTemplateDirective,
3537
IgxCellHeaderTemplateDirective,
3638
IgxCellFooterTemplateDirective,

projects/igniteui-angular/src/lib/grids/columns/templates.directive.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,11 @@ export class IgxCollapsibleIndicatorTemplateDirective {
5050

5151
constructor(public template: TemplateRef<any>) { }
5252
}
53+
54+
@Directive({
55+
selector: '[igxSummary]'
56+
})
57+
export class IgxSummaryTemplateDirective {
58+
59+
constructor(public template: TemplateRef<any>) { }
60+
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ export interface ColumnType {
157157
filteringExpressionsTree: FilteringExpressionsTree;
158158
hasSummary: boolean;
159159
summaries: any;
160+
summaryTemplate: TemplateRef<any>;
160161
pinned: boolean;
161162
expanded: boolean;
162163
selected: boolean;
@@ -373,6 +374,7 @@ export interface GridType extends IGridDataBindable {
373374
dataWithAddedInTransactionRows: any[];
374375
transactions: TransactionService<Transaction, State>;
375376
defaultSummaryHeight: number;
377+
summaryRowHeight: number;
376378
rowEditingOverlay: IgxToggleDirective;
377379
totalRowsCountAfterFilter: number;
378380
_totalRecords: number;

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

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,25 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
228228
@Input()
229229
public loadingGridTemplate: TemplateRef<any>;
230230

231+
/**
232+
* Get/Set IgxSummaryRow height
233+
*/
234+
@Input()
235+
public set summaryRowHeight(value: number) {
236+
this._summaryRowHeight = value | 0;
237+
this.summaryService.summaryHeight = value;
238+
if (!this._init) {
239+
this.reflow();
240+
}
241+
}
242+
243+
public get summaryRowHeight(): number {
244+
if (this.hasSummarizedColumns && this.rootSummariesEnabled) {
245+
return this._summaryRowHeight || this.summaryService.calcMaxSummaryHeight();
246+
}
247+
return 0;
248+
}
249+
231250
/**
232251
* Controls the copy behavior of the grid.
233252
*/
@@ -2517,10 +2536,6 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
25172536
* @hidden @internal
25182537
*/
25192538
public tfootHeight: number;
2520-
/**
2521-
* @hidden @internal
2522-
*/
2523-
public summariesHeight: number;
25242539

25252540
/**
25262541
* @hidden @internal
@@ -2759,6 +2774,7 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
27592774
private _summaryPosition: GridSummaryPosition = GridSummaryPosition.bottom;
27602775
private _summaryCalculationMode: GridSummaryCalculationMode = GridSummaryCalculationMode.rootAndChildLevels;
27612776
private _showSummaryOnCollapse = false;
2777+
private _summaryRowHeight = 0;
27622778
private _cellSelectionMode: GridSelectionMode = GridSelectionMode.multiple;
27632779
private _rowSelectionMode: GridSelectionMode = GridSelectionMode.none;
27642780
private _selectRowOnClick = true;
@@ -3227,7 +3243,9 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
32273243

32283244
this.onDensityChanged.pipe(destructor).subscribe(() => {
32293245
this.crudService.endEdit(false);
3246+
if (this._summaryRowHeight === 0) {
32303247
this.summaryService.summaryHeight = 0;
3248+
}
32313249
this.notifyChanges(true);
32323250
});
32333251
}
@@ -6331,10 +6349,6 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
63316349
*/
63326350
protected calculateGridHeight() {
63336351
this.calcGridHeadRow();
6334-
this.summariesHeight = 0;
6335-
if (this.hasSummarizedColumns && this.rootSummariesEnabled) {
6336-
this.summariesHeight = this.summaryService.calcMaxSummaryHeight();
6337-
}
63386352

63396353
this.calcHeight = this._calculateGridBodyHeight();
63406354
if (this.pinnedRowHeight && this.calcHeight) {
@@ -6359,7 +6373,7 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
63596373
* @hidden
63606374
*/
63616375
protected getFooterHeight(): number {
6362-
return this.summariesHeight || this.getComputedHeight(this.tfoot.nativeElement);
6376+
return this.summaryRowHeight || this.getComputedHeight(this.tfoot.nativeElement);
63636377
}
63646378
/**
63656379
* @hidden

0 commit comments

Comments
 (0)