Skip to content

Commit b813a52

Browse files
committed
chore(pivot): Add display density to pivot sample
1 parent 92c16ef commit b813a52

File tree

3 files changed

+29
-5
lines changed

3 files changed

+29
-5
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
11
<div class="sample-column">
2+
<h4>Display Density</h4>
3+
<div class="density-chooser">
4+
<igx-buttongroup>
5+
<button igxButton [disabled]="grid1.displayDensity === compact"
6+
(click)="setDensity('compact')">Compact</button>
7+
<button igxButton [disabled]="grid1.displayDensity === cosy"
8+
(click)="setDensity('cosy')">Cosy</button>
9+
<button igxButton [disabled]="grid1.displayDensity === comfortable"
10+
(click)="setDensity('comfortable')">Comfortable</button>
11+
</igx-buttongroup>
12+
</div>
213
<igx-pivot-grid #grid1 [data]="origData" [width]="'100%'" [height]="'100%'" [defaultExpandState]='true' [pivotConfiguration]="pivotConfigHierarchy">
314
</igx-pivot-grid>
415
</div>

src/app/pivot-grid/pivot-grid.sample.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
margin: 0 0 0 0 !important;
44
}
55

6+
.density-chooser {
7+
margin-bottom: 16px;
8+
}
9+
610
:host ::ng-deep {
711
.upFont {
812
color: lightgreen;

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

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import {
44
IgxPivotGridComponent,
55
IPivotConfiguration,
66
PivotAggregation,
7-
IgxPivotDateDimension
7+
IgxPivotDateDimension,
8+
DisplayDensity
89
} from 'igniteui-angular';
910
import { HIERARCHICAL_SAMPLE_DATA } from '../shared/sample-data';
1011

@@ -41,6 +42,9 @@ export class IgxTotalSaleAggregate {
4142
})
4243
export class PivotGridSampleComponent {
4344
@ViewChild('grid1', { static: true }) public grid1: IgxPivotGridComponent;
45+
public comfortable: DisplayDensity = DisplayDensity.comfortable;
46+
public cosy: DisplayDensity = DisplayDensity.cosy;
47+
public compact: DisplayDensity = DisplayDensity.compact;
4448

4549
public pivotConfigHierarchy: IPivotConfiguration = {
4650
columns: [
@@ -80,7 +84,7 @@ export class PivotGridSampleComponent {
8084
key: 'SUM',
8185
aggregator: IgxPivotNumericAggregate.sum,
8286
label: 'Sum'
83-
},
87+
},
8488
enabled: true,
8589
styles: {
8690
upFont: (rowData: any, columnKey: any): boolean => rowData[columnKey] > 300,
@@ -101,11 +105,11 @@ export class PivotGridSampleComponent {
101105
key: 'SUM',
102106
aggregator: IgxTotalSaleAggregate.totalSale,
103107
label: 'Sum of Sale'
104-
},{
108+
}, {
105109
key: 'MIN',
106110
aggregator: IgxTotalSaleAggregate.totalMin,
107111
label: 'Minimum of Sale'
108-
},{
112+
}, {
109113
key: 'MAX',
110114
aggregator: IgxTotalSaleAggregate.totalMax,
111115
label: 'Maximum of Sale'
@@ -149,5 +153,10 @@ export class PivotGridSampleComponent {
149153
{
150154
ProductCategory: 'Clothing', UnitPrice: 16.05, SellerName: 'Walter',
151155
Country: 'Bulgaria', City: 'Plovdiv', Date: '02/19/2020', UnitsSold: 492
152-
}];
156+
}
157+
];
158+
159+
public setDensity(density: DisplayDensity) {
160+
this.grid1.displayDensity = density;
161+
}
153162
}

0 commit comments

Comments
 (0)