Skip to content

Commit 1f2e747

Browse files
author
ddaribo
committed
feat(grid): add summaryRowHeight property
1 parent 6b601cb commit 1f2e747

File tree

10 files changed

+77
-67
lines changed

10 files changed

+77
-67
lines changed

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

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1262,36 +1262,7 @@ export class IgxColumnComponent implements AfterContentInit, OnDestroy {
12621262
public set filterCellTemplate(template: TemplateRef<any>) {
12631263
this._filterCellTemplate = template;
12641264
}
1265-
/**
1266-
* Returns a reference to the `customSummaryCellTemplate`.
1267-
* ```typescript
1268-
* let customSummaryCellTemplate = this.column.customSummaryCellTemplate;
1269-
* ```
1270-
*
1271-
* @memberof IgxColumnComponent
1272-
*/
1273-
@notifyChanges()
1274-
@WatchColumnChanges()
1275-
@Input()
1276-
public get customSummaryCellTemplate(): TemplateRef<any> {
1277-
return this._customSummaryCellTemplate;
1278-
}
1279-
/**
1280-
* Sets the custom summary cell template.
1281-
* ```html
1282-
* <ng-template igxCustomSummaryCell let-summaryResults>
1283-
* {{ summaryResults[0].label }}
1284-
* </ng-template>
1285-
* ```
1286-
* ```typescript
1287-
*
1288-
* ```
1289-
*
1290-
* @memberof IgxColumnComponent
1291-
*/
1292-
public set customSummaryCellTemplate(template: TemplateRef<any>) {
1293-
this._customSummaryCellTemplate = template;
1294-
}
1265+
12951266
/**
12961267
* Gets the cells of the column.
12971268
* ```typescript
@@ -1622,10 +1593,6 @@ export class IgxColumnComponent implements AfterContentInit, OnDestroy {
16221593
* @hidden
16231594
*/
16241595
protected _filterCellTemplate: TemplateRef<any>;
1625-
/**
1626-
* @hidden
1627-
*/
1628-
protected _customSummaryCellTemplate: TemplateRef<any>;
16291596
/**
16301597
* @hidden
16311598
*/
@@ -1737,9 +1704,6 @@ export class IgxColumnComponent implements AfterContentInit, OnDestroy {
17371704
if (this.filterCellTemplateDirective) {
17381705
this._filterCellTemplate = this.filterCellTemplateDirective.template;
17391706
}
1740-
if (this.customSummaryCellTemplateDirective) {
1741-
this._customSummaryCellTemplate = this.customSummaryCellTemplateDirective.template;
1742-
}
17431707
if (!this._columnPipeArgs.format) {
17441708
this._columnPipeArgs.format = this.dataType === GridColumnDataType.Time ?
17451709
DEFAULT_TIME_FORMAT : this.dataType === GridColumnDataType.DateTime ?

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ export interface GridType extends IGridDataBindable {
6868
dataView: any[];
6969
transactions: TransactionService<Transaction, State>;
7070
defaultSummaryHeight: number;
71+
summaryRowHeight: number;
7172

7273
rowEditTabs: any;
7374

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+
* Sets summaryRow height
233+
*/
234+
@Input()
235+
public set summaryRowHeight(value: number) {
236+
this._summaryRowHeight = value;
237+
this.summaryService.summaryHeight = value;
238+
// if (value === 0) {
239+
//this.summaryService.calcMaxSummaryHeight();
240+
// }
241+
if (!this._init) {
242+
this.reflow();
243+
}
244+
}
245+
246+
public get summaryRowHeight(): number {
247+
return this._summaryRowHeight || this.summaryService.summaryHeight;
248+
}
249+
231250
/**
232251
* Controls the copy behavior of the grid.
233252
*/
@@ -2592,10 +2611,6 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
25922611
* @hidden @internal
25932612
*/
25942613
public tfootHeight: number;
2595-
/**
2596-
* @hidden @internal
2597-
*/
2598-
public summariesHeight: number;
25992614

26002615
/**
26012616
* @hidden @internal
@@ -2850,6 +2865,7 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
28502865
private _summaryPosition: GridSummaryPosition = GridSummaryPosition.bottom;
28512866
private _summaryCalculationMode: GridSummaryCalculationMode = GridSummaryCalculationMode.rootAndChildLevels;
28522867
private _showSummaryOnCollapse = false;
2868+
private _summaryRowHeight = 0;
28532869
private _cellSelectionMode: GridSelectionMode = GridSelectionMode.multiple;
28542870
private _rowSelectionMode: GridSelectionMode = GridSelectionMode.none;
28552871
private _selectRowOnClick = true;
@@ -3320,7 +3336,9 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
33203336

33213337
this.onDensityChanged.pipe(destructor).subscribe(() => {
33223338
this.crudService.endEdit(false);
3339+
if (this._summaryRowHeight === 0) {
33233340
this.summaryService.summaryHeight = 0;
3341+
}
33243342
this.notifyChanges(true);
33253343
});
33263344
}
@@ -6412,10 +6430,6 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
64126430
*/
64136431
protected calculateGridHeight() {
64146432
this.calcGridHeadRow();
6415-
this.summariesHeight = 0;
6416-
if (this.hasSummarizedColumns && this.rootSummariesEnabled) {
6417-
this.summariesHeight = this.summaryService.calcMaxSummaryHeight();
6418-
}
64196433

64206434
this.calcHeight = this._calculateGridBodyHeight();
64216435
if (this.pinnedRowHeight && this.calcHeight) {
@@ -6440,7 +6454,7 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
64406454
* @hidden
64416455
*/
64426456
protected getFooterHeight(): number {
6443-
return this.summariesHeight || this.getComputedHeight(this.tfoot.nativeElement);
6457+
return this.summaryRowHeight || this.getComputedHeight(this.tfoot.nativeElement);
64446458
}
64456459
/**
64466460
* @hidden

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,14 +157,14 @@
157157
</div>
158158

159159

160-
<div class="igx-grid__tfoot" role="rowgroup" [style.height.px]='summariesHeight' #tfoot>
160+
<div class="igx-grid__tfoot" role="rowgroup" [style.height.px]='summaryRowHeight' #tfoot>
161161
<div tabindex="0" (focus)="navigation.focusFirstCell(false)" (keydown)="navigation.summaryNav($event)" [attr.aria-activedescendant]="activeDescendant">
162-
<igx-grid-summary-row [style.width.px]='calcWidth' [style.height.px]='summariesHeight'
162+
<igx-grid-summary-row [style.width.px]='calcWidth' [style.height.px]='summaryRowHeight'
163163
*ngIf="hasSummarizedColumns && rootSummariesEnabled" [gridID]="id" role="row"
164164
[summaries]="id | igxGridSummaryDataPipe:summaryService.retriggerRootPipe" [index]="dataView.length"
165165
class="igx-grid__summaries" #summaryRow>
166166
</igx-grid-summary-row>
167-
<div class="igx-grid__tfoot-thumb" [hidden]='!hasVerticalScroll()' [style.height.px]='summariesHeight'
167+
<div class="igx-grid__tfoot-thumb" [hidden]='!hasVerticalScroll()' [style.height.px]='summaryRowHeight'
168168
[style.width.px]="scrollSize"></div>
169169
</div>
170170
</div>

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,15 +118,15 @@
118118
<div igxOverlayOutlet #igxBodyOverlayOutlet="overlay-outlet"></div>
119119
</div>
120120

121-
<div class="igx-grid__tfoot" role="rowgroup" [style.height.px]='summariesHeight' #tfoot>
121+
<div class="igx-grid__tfoot" role="rowgroup" [style.height.px]='summaryRowHeight' #tfoot>
122122
<div tabindex="0" (focus)="navigation.focusFirstCell(false)" [attr.aria-activedescendant]="activeDescendant"
123123
(keydown)="navigation.summaryNav($event)">
124-
<igx-grid-summary-row [style.width.px]='calcWidth' [style.height.px]='summariesHeight'
124+
<igx-grid-summary-row [style.width.px]='calcWidth' [style.height.px]='summaryRowHeight'
125125
*ngIf="hasSummarizedColumns && rootSummariesEnabled" [gridID]="id" role="row"
126126
[summaries]="id | igxGridSummaryDataPipe:summaryService.retriggerRootPipe" [index]="dataView.length"
127127
class="igx-grid__summaries" #summaryRow>
128128
</igx-grid-summary-row>
129-
<div class="igx-grid__tfoot-thumb" [hidden]='!hasVerticalScroll()' [style.height.px]='summariesHeight'
129+
<div class="igx-grid__tfoot-thumb" [hidden]='!hasVerticalScroll()' [style.height.px]='summaryRowHeight'
130130
[style.width.px]="scrollSize"></div>
131131
</div>
132132
</div>

projects/igniteui-angular/src/lib/grids/summaries/grid-summary.service.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,9 @@ export class IgxGridSummaryService {
130130
}
131131

132132
public resetSummaryHeight() {
133-
this.summaryHeight = 0;
133+
if (this.summaryHeight !== this.grid.summaryRowHeight) {
134+
this.summaryHeight = 0;
135+
}
134136
this.grid.summaryPipeTrigger++;
135137
if (this.grid.rootSummariesEnabled) {
136138
this.retriggerRootPipe++;

projects/igniteui-angular/src/lib/grids/summaries/summary-cell.component.html

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
<ng-container *ngIf="hasSummary">
2-
<ng-container
3-
*ngTemplateOutlet="column.customSummaryCellTemplate ? column.customSummaryCellTemplate : defaultSummary; context: { $implicit: summaryResults, summaryResults: summaryResults}">
2+
<ng-container *ngTemplateOutlet="column.customSummaryCellTemplateDirective ? customSummary : defaultSummary">
43
</ng-container>
5-
4+
</ng-container>
5+
<ng-template #customSummary>
6+
<ng-container *ngTemplateOutlet="column.customSummaryCellTemplateDirective.template; context: { $implicit: summaryResults }">
7+
</ng-container>
8+
</ng-template>
69
<ng-template #defaultSummary>
710
<ng-container *ngFor="let summary of summaryResults" >
811
<div class="igx-grid-summary__item" [style.height.px]="itemHeight">
@@ -36,4 +39,3 @@
3639
</div>
3740
</ng-container>
3841
</ng-template>
39-
</ng-container>

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,15 +111,15 @@
111111
<div igxOverlayOutlet #igxBodyOverlayOutlet="overlay-outlet"></div>
112112
</div>
113113

114-
<div class="igx-grid__tfoot" role="rowgroup" [style.height.px]='summariesHeight' #tfoot>
114+
<div class="igx-grid__tfoot" role="rowgroup" [style.height.px]='summaryRowHeight' #tfoot>
115115
<div tabindex="0" (focus)="navigation.focusFirstCell(false)"
116116
(keydown)="navigation.summaryNav($event)" [attr.aria-activedescendant]="activeDescendant">
117-
<igx-grid-summary-row [style.width.px]='calcWidth' [style.height.px]='summariesHeight'
117+
<igx-grid-summary-row [style.width.px]='calcWidth' [style.height.px]='summaryRowHeight'
118118
*ngIf="hasSummarizedColumns && rootSummariesEnabled" [gridID]="id" role="row"
119119
[summaries]="id | igxGridSummaryDataPipe:summaryService.retriggerRootPipe" [index]="dataView.length"
120120
class="igx-grid__summaries" #summaryRow>
121121
</igx-grid-summary-row>
122-
<div class="igx-grid__tfoot-thumb" [hidden]='!hasVerticalScroll()' [style.height.px]='summariesHeight'
122+
<div class="igx-grid__tfoot-thumb" [hidden]='!hasVerticalScroll()' [style.height.px]='summaryRowHeight'
123123
[style.width.px]="scrollSize"></div>
124124
</div>
125125
</div>

src/app/grid-summaries/grid-summaries.sample.html

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1+
<div class="density-chooser">
2+
<igx-buttongroup [values]="displayDensities" (selected)="selectDensity($event)"></igx-buttongroup>
3+
</div>
14
<igx-grid #grid1 [pinning]="pinningConfig" [data]="data" [autoGenerate]="false" [displayDensity]="'compact'" [width]="w" [height]="h"
2-
[allowFiltering]="true" [filterMode]="'excelStyleFilter'" [summaryCalculationMode]="'rootAndChildLevels'">
5+
[allowFiltering]="true" [filterMode]="'excelStyleFilter'" [summaryCalculationMode]="'rootAndChildLevels'" [showSummaryOnCollapse]="true"
6+
[summaryRowHeight]="rh" [rowSelection]="rowSelection ? 'multiple' : 'none'" [displayDensity]="density">
37
<igx-grid-toolbar *ngIf="showToolbar" [displayDensity]="grid1.displayDensity">
48
<igx-grid-toolbar-title>Grid Toolbar</igx-grid-toolbar-title>
59
<igx-grid-toolbar-actions>
@@ -31,9 +35,14 @@
3135
${{val}}
3236
</ng-template>
3337
<ng-template igxCustomSummaryCell let-summaryResults>
34-
<span>Custom summary cell:</span>
35-
<span>Number of Summaries: {{ summaryResults.length }}</span>
36-
<span>FirstSummary - {{ summaryResults[0].label }}: {{ summaryResults[0].summaryResult }}</span>
38+
<div style="font-size: 0.75rem">
39+
<span>Custom summary cell:</span><br>
40+
<span>Number of Summaries: {{ summaryResults.length }}</span><br>
41+
<span>First Summary - {{ summaryResults[0].label }}: {{ summaryResults[0].summaryResult }}</span><br>
42+
<span>Second Summary - {{ summaryResults[1].label }}: {{ summaryResults[1].summaryResult }}</span><br>
43+
<span>Third Summary - {{ summaryResults[2].label }}: {{ summaryResults[2].summaryResult }}</span><br>
44+
<span> Fourth Summary - {{ summaryResults[3].label }}: {{ summaryResults[3].summaryResult }}</span><br>
45+
</div>
3746
</ng-template>
3847
</igx-column>
3948
<igx-column field="OrderDate" [width]="cw" [dataType]="'date'" [hasSummary]="false" [sortable]="true">
@@ -60,6 +69,10 @@
6069
<label> Columns Width </label>
6170
<input [(ngModel)]="cw">
6271
</div>
72+
<div class="properties-input">
73+
<label> Summary Row Height </label>
74+
<input type="number" [(ngModel)]="rh">
75+
</div>
6376

6477
<igx-switch [(ngModel)]="grid1.paging">Enable Paging</igx-switch>
6578
<igx-switch [(ngModel)]="grid1.allowFiltering">allowFiltering</igx-switch>
@@ -73,6 +86,7 @@
7386
<igx-switch [(ngModel)]="disablePinning">ReorderLevel disablePinning</igx-switch>
7487
<igx-switch [(ngModel)]="hasSummaryUnit">hasSummaryUnit</igx-switch>
7588
<igx-switch [(ngModel)]="hasHidden">hasHidden</igx-switch>
89+
<igx-switch [(ngModel)]="rowSelection">Row Selection</igx-switch>
7690

7791
<button (click)="enableSummary()"> Enable Summary for column ReorderLevel</button>
7892
<button (click)="disableSummary()">Disable Summary</button>

src/app/grid-summaries/grid-summaries.sample.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, ViewChild } from '@angular/core';
1+
import { Component, OnInit, ViewChild } from '@angular/core';
22
import {
33
IgxGridComponent,
44
IgxNumberSummaryOperand,
@@ -30,7 +30,7 @@ class MySummary extends IgxNumberSummaryOperand {
3030
styleUrls: ['./grid-summaries.component.scss'],
3131
templateUrl: 'grid-summaries.sample.html'
3232
})
33-
export class GridSummaryComponent {
33+
export class GridSummaryComponent implements OnInit {
3434

3535
@ViewChild('grid1', { read: IgxGridComponent, static: true })
3636
private grid1: IgxGridComponent;
@@ -40,6 +40,7 @@ export class GridSummaryComponent {
4040
public w = '1200px';
4141
public h = '500px';
4242
public cw = '200px';
43+
public rh = 0;
4344

4445
public groupable = false;
4546
public filterable = true;
@@ -50,7 +51,9 @@ export class GridSummaryComponent {
5051
public columnHiding = false;
5152
public columnPinning = false;
5253
public pinningConfig: IPinningConfig = { columns: ColumnPinningPosition.End };
53-
54+
public rowSelection = false;
55+
public density = 'compact';
56+
public displayDensities;
5457

5558
public data = [{
5659
__metadata: {
@@ -707,6 +710,16 @@ export class GridSummaryComponent {
707710
this.data[i]['Index'] = i;
708711
}
709712
}
713+
public ngOnInit(): void {
714+
this.displayDensities = [
715+
{ label: 'compact', selected: this.density === 'compact', togglable: true },
716+
{ label: 'cosy', selected: this.density === 'cosy', togglable: true },
717+
{ label: 'comfortable', selected: this.density === 'comfortable', togglable: true }];
718+
}
719+
720+
public selectDensity(event) {
721+
this.density = this.displayDensities[event.index].label;
722+
}
710723

711724
public updateData() {
712725
const d = [].concat(this.data).concat(this.data2);

0 commit comments

Comments
 (0)