Skip to content

Commit 76f697d

Browse files
authored
Merge branch 'master' into SKrastev/drag-drop-refactor
2 parents f26ec3f + e5617b1 commit 76f697d

File tree

17 files changed

+695
-190
lines changed

17 files changed

+695
-190
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,17 @@ All notable changes for each version of this project will be documented in this
1414
- `IgxGrid`
1515
- `IgxColumnGroup`
1616
- Re-templating the column group header is now possible using the `headerTemplate` input property or the `igxHeader` directive.
17+
- `igx-grid-footer`
18+
- You can use this to insert a custom footer in the grids.
19+
```html
20+
<igx-grid>
21+
<igx-grid-footer>
22+
Custom content
23+
</igx-grid-footer>
24+
</igx-grid>
25+
```
26+
- `igx-paginator`
27+
- Replaces the current paginator in all grids. Can be used as a standalone component.
1728
- `IgxCombo`
1829
- Input `[overlaySettings]` - allows an object of type `OverlaySettings` to be passed. These custom overlay settings control how the drop-down list displays.
1930

projects/igniteui-angular/src/lib/core/styles/components/grid-paginator/_grid-paginator-theme.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@
7373
z-index: 1;
7474
padding: map-get($paginator-padding, 'comfortable');
7575
height: map-get($paginator-height, 'comfortable');
76-
76+
width: 100%;
77+
7778
&:empty {
7879
padding: 0;
7980
}

projects/igniteui-angular/src/lib/core/styles/components/grid/_grid-component.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@
9696
@extend %grid-tfoot-thumb !optional;
9797
}
9898

99+
@include e(footer) {
100+
@extend %grid-footer !optional;
101+
}
102+
99103
@include e(tr) {
100104
@extend %grid-row !optional;
101105

projects/igniteui-angular/src/lib/core/styles/components/grid/_grid-theme.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -732,6 +732,10 @@
732732
z-index: 10001;
733733
}
734734

735+
%grid-footer {
736+
grid-row: 7;
737+
}
738+
735739
%grid-display-container-thead {
736740
width: 100%;
737741
overflow: visible;

projects/igniteui-angular/src/lib/expansion-panel/expansion-panel.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1010,7 +1010,7 @@ describe('igxExpansionPanel', () => {
10101010
expect(grid.attributes.getNamedItem('ng-reflect-auto-generate').nodeValue).toEqual('true');
10111011
expect(grid.attributes.getNamedItem('ng-reflect-width').nodeValue).toEqual(fixture.componentInstance.width);
10121012
expect(grid.attributes.getNamedItem('ng-reflect-height').nodeValue).toEqual(fixture.componentInstance.height);
1013-
expect(grid.childElementCount).toEqual(5);
1013+
expect(grid.childElementCount).toEqual(6);
10141014
}));
10151015
it('Should apply all appropriate classes on combo initialization_image + text content', fakeAsync(() => {
10161016
const fixture: ComponentFixture<IgxExpansionPanelImageComponent> = TestBed.createComponent(IgxExpansionPanelImageComponent);

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

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1737,8 +1737,8 @@ export abstract class IgxGridBaseComponent extends DisplayDensityBase implements
17371737
/**
17381738
* @hidden
17391739
*/
1740-
@ViewChild('paginator', { read: ElementRef, static: false })
1741-
public paginator: ElementRef;
1740+
@ViewChild('footer', { read: ElementRef, static: false })
1741+
public footer: ElementRef;
17421742

17431743
/**
17441744
* @hidden
@@ -3230,28 +3230,54 @@ export abstract class IgxGridBaseComponent extends DisplayDensityBase implements
32303230
}
32313231

32323232
/**
3233-
* Returns the total number of records.
3234-
* Only functions when paging is enabled.
3233+
* Returns if the current page is the first page.
32353234
* ```typescript
3236-
* const totalRecords = this.grid.totalRecords;
3235+
* const firstPage = this.grid.isFirstPage;
32373236
* ```
32383237
* @memberof IgxGridBaseComponent
32393238
*/
3240-
get totalRecords(): number {
3241-
if (this.pagingState) {
3242-
return this.pagingState.metadata.countRecords;
3239+
get isFirstPage(): boolean {
3240+
return this.page === 0;
3241+
}
3242+
3243+
/**
3244+
* Goes to the next page of the `IgxGridComponent`, if the grid is not already at the last page.
3245+
* ```typescript
3246+
* this.grid1.nextPage();
3247+
* ```
3248+
* @memberof IgxGridBaseComponent
3249+
*/
3250+
public nextPage(): void {
3251+
if (!this.isLastPage) {
3252+
this.page += 1;
32433253
}
32443254
}
32453255

32463256
/**
3247-
* Returns if the current page is the first page.
3257+
* Goes to the previous page of the `IgxGridComponent`, if the grid is not already at the first page.
32483258
* ```typescript
3249-
* const firstPage = this.grid.isFirstPage;
3259+
* this.grid1.previousPage();
32503260
* ```
32513261
* @memberof IgxGridBaseComponent
32523262
*/
3253-
get isFirstPage(): boolean {
3254-
return this.page === 0;
3263+
public previousPage(): void {
3264+
if (!this.isFirstPage) {
3265+
this.page -= 1;
3266+
}
3267+
}
3268+
3269+
/**
3270+
* Returns the total number of records.
3271+
* Only functions when paging is enabled.
3272+
* ```typescript
3273+
* const totalRecords = this.grid.totalRecords;
3274+
* ```
3275+
* @memberof IgxGridBaseComponent
3276+
*/
3277+
get totalRecords(): number {
3278+
if (this.pagingState) {
3279+
return this.pagingState.metadata.countRecords;
3280+
}
32553281
}
32563282

32573283
/**
@@ -3444,32 +3470,6 @@ export abstract class IgxGridBaseComponent extends DisplayDensityBase implements
34443470
this.onColumnMovingEnd.emit(args);
34453471
}
34463472

3447-
/**
3448-
* Goes to the next page of the `IgxGridComponent`, if the grid is not already at the last page.
3449-
* ```typescript
3450-
* this.grid1.nextPage();
3451-
* ```
3452-
* @memberof IgxGridBaseComponent
3453-
*/
3454-
public nextPage(): void {
3455-
if (!this.isLastPage) {
3456-
this.page += 1;
3457-
}
3458-
}
3459-
3460-
/**
3461-
* Goes to the previous page of the `IgxGridComponent`, if the grid is not already at the first page.
3462-
* ```typescript
3463-
* this.grid1.previousPage();
3464-
* ```
3465-
* @memberof IgxGridBaseComponent
3466-
*/
3467-
public previousPage(): void {
3468-
if (!this.isFirstPage) {
3469-
this.page -= 1;
3470-
}
3471-
}
3472-
34733473
/**
34743474
* Goes to the desired page index.
34753475
* ```typescript
@@ -4095,9 +4095,9 @@ export abstract class IgxGridBaseComponent extends DisplayDensityBase implements
40954095
*/
40964096
protected getPagingHeight(): number {
40974097
let pagingHeight = 0;
4098-
if (this.paging && this.paginator) {
4099-
pagingHeight = this.paginator.nativeElement.firstElementChild ?
4100-
this.paginator.nativeElement.offsetHeight : 0;
4098+
if (this.footer) {
4099+
pagingHeight = this.footer.nativeElement.firstElementChild ?
4100+
this.footer.nativeElement.offsetHeight : 0;
41014101
}
41024102
return pagingHeight;
41034103
}

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import { IgxGridHeaderComponent } from './grid-header.component';
2323
import { IgxGridToolbarComponent } from './grid-toolbar.component';
2424
import { IgxGridFilteringCellComponent } from './filtering/grid-filtering-cell.component';
2525
import { IgxGridFilteringRowComponent } from './filtering/grid-filtering-row.component';
26+
import { IgxGridFooterComponent } from './grid-footer/grid-footer.component';
2627
import {
2728
IgxCellEditorTemplateDirective,
2829
IgxCellFooterTemplateDirective,
@@ -59,6 +60,7 @@ import { IgxSummaryDataPipe } from './summaries/grid-root-summary.pipe';
5960
import { IgxGridSelectionService } from '../core/grid-selection';
6061
import { IgxGridSummaryService } from './summaries/grid-summary.service';
6162
import { IgxProgressBarModule } from '../progressbar/progressbar.component';
63+
import { IgxPaginatorModule } from '../paginator/paginator.component';
6264
import { IgxFilterModule } from '../directives/filter/filter.directive';
6365
import { IgxGridPipesModule } from './grid-pipes.module';
6466
import { IgxGridExcelStyleFilteringModule } from './filtering/excel-style/grid.excel-style-filtering.module';
@@ -99,7 +101,8 @@ import { IgxRowDragModule } from './row-drag.directive';
99101
IgxSummaryCellComponent,
100102
IgxGridDragSelectDirective,
101103
IgxGridColumnResizerComponent,
102-
IgxFilterCellTemplateDirective
104+
IgxFilterCellTemplateDirective,
105+
IgxGridFooterComponent
103106
],
104107
entryComponents: [
105108
IgxColumnComponent,
@@ -159,7 +162,9 @@ import { IgxRowDragModule } from './row-drag.directive';
159162
IgxGridPipesModule,
160163
IgxGridExcelStyleFilteringModule,
161164
IgxFilterCellTemplateDirective,
162-
IgxRowDragModule
165+
IgxRowDragModule,
166+
IgxPaginatorModule,
167+
IgxGridFooterComponent
163168
],
164169
imports: [
165170
CommonModule,
@@ -187,7 +192,8 @@ import { IgxRowDragModule } from './row-drag.directive';
187192
IgxFilterModule,
188193
IgxGridPipesModule,
189194
IgxGridExcelStyleFilteringModule,
190-
IgxRowDragModule
195+
IgxRowDragModule,
196+
IgxPaginatorModule
191197
],
192198
providers: [
193199
IgxGridSelectionService,
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { Component } from '@angular/core';
2+
3+
@Component({
4+
selector: 'igx-grid-footer',
5+
template: '<ng-content></ng-content>'
6+
})
7+
export class IgxGridFooterComponent {
8+
}

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

Lines changed: 12 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2,39 +2,6 @@
22
[displayDensity]="displayDensity" #toolbar>
33
</igx-grid-toolbar>
44

5-
<ng-template #defaultPager let-api>
6-
<div class="igx-grid-paginator__select">
7-
<label class="igx-grid-paginator__label">{{ resourceStrings.igx_grid_paginator_label }}</label>
8-
<div class="igx-grid-paginator__select-input">
9-
<igx-select [(ngModel)]="api.perPage" [displayDensity]="paginatorSelectDisplayDensity()" type="border">
10-
<igx-select-item [value]="val"
11-
*ngFor="let val of [api.perPage, 5, 10, 15, 25, 50, 100, 500] | paginatorOptions">
12-
{{val}}
13-
</igx-select-item>
14-
</igx-select>
15-
</div>
16-
</div>
17-
<div class="igx-grid-paginator__pager">
18-
<button [disabled]="api.isFirstPage" (click)="api.paginate(0)" igxButton="icon" igxRipple
19-
igxRippleCentered="true">
20-
<igx-icon fontSet="material">first_page</igx-icon>
21-
</button>
22-
<button [disabled]="api.isFirstPage" (click)="api.previousPage()" igxButton="icon" igxRipple
23-
igxRippleCentered="true">
24-
<igx-icon fontSet="material">chevron_left</igx-icon>
25-
</button>
26-
<span>{{ api.page + 1 }} of {{ api.totalPages }}</span>
27-
<button [disabled]="api.isLastPage" (click)="api.nextPage()" igxRipple igxRippleCentered="true"
28-
igxButton="icon">
29-
<igx-icon fontSet="material">chevron_right</igx-icon>
30-
</button>
31-
<button [disabled]="api.isLastPage" (click)="api.paginate(api.totalPages - 1)" igxButton="icon" igxRipple
32-
igxRippleCentered="true">
33-
<igx-icon fontSet="material">last_page</igx-icon>
34-
</button>
35-
</div>
36-
</ng-template>
37-
385
<div [style.width.px]='outerWidth' class="igx-grid__grouparea"
396
*ngIf="groupingExpressions.length > 0 || hasGroupableColumns" #groupArea>
407
<igx-chips-area (onReorder)="chipsOrderChanged($event)" (onMoveEnd)="chipsMovingEnded()">
@@ -198,12 +165,21 @@
198165
</div>
199166
</div>
200167

201-
<div [ngClass]="paginatorClassName()" *ngIf="paging && totalRecords" #paginator>
202-
<ng-container
203-
*ngTemplateOutlet="paginationTemplate ? paginationTemplate : defaultPager; context: { $implicit: this }">
168+
<div class="igx-grid__footer" #footer>
169+
<ng-content select="igx-grid-footer"></ng-content>
170+
<ng-container *ngIf="paging && totalRecords">
171+
<ng-container
172+
*ngTemplateOutlet="paginationTemplate ? paginationTemplate : defaultPaginator; context: {$implicit: this}">
173+
</ng-container>
204174
</ng-container>
205175
</div>
206176

177+
<ng-template #defaultPaginator>
178+
<igx-paginator [displayDensity]="displayDensity" [(page)]="page"
179+
[totalRecords]="filteredData ? filteredData.length : totalRecords" [(perPage)]="perPage">
180+
</igx-paginator>
181+
</ng-template>
182+
207183
<ng-template #emptyFilteredGrid>
208184
<span class="igx-grid__tbody-message">{{emptyFilteredGridMessage}}</span>
209185
</ng-template>

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

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4305,6 +4305,53 @@ describe('IgxGrid Component Tests', () => {
43054305
expect(parseInt(window.getComputedStyle(grid.nativeElement).height, 10)).toBe(300);
43064306
});
43074307
});
4308+
4309+
describe('IgxGrid - footer section', () => {
4310+
configureTestSuite();
4311+
beforeEach(async(() => {
4312+
TestBed.configureTestingModule({
4313+
declarations: [
4314+
IgxGridWithCustomFooterComponent
4315+
],
4316+
imports: [
4317+
NoopAnimationsModule, IgxGridModule]
4318+
}).compileComponents();
4319+
}));
4320+
4321+
it('should be able to display custom content', () => {
4322+
const fix = TestBed.createComponent(IgxGridWithCustomFooterComponent);
4323+
fix.detectChanges();
4324+
4325+
const footer = fix.debugElement.query(By.css('igx-grid-footer')).nativeElement;
4326+
const footerContent = footer.textContent.trim();
4327+
4328+
expect(footerContent).toEqual('Custom content');
4329+
});
4330+
});
4331+
4332+
describe('IgxGrid - with custom pagination template', () => {
4333+
configureTestSuite();
4334+
beforeEach(async(() => {
4335+
TestBed.configureTestingModule({
4336+
declarations: [
4337+
IgxGridWithCustomPaginationTemplateComponent
4338+
],
4339+
imports: [
4340+
NoopAnimationsModule, IgxGridModule]
4341+
}).compileComponents();
4342+
}));
4343+
4344+
it('should have access to grid context', () => {
4345+
const fix = TestBed.createComponent(IgxGridWithCustomPaginationTemplateComponent);
4346+
fix.detectChanges();
4347+
4348+
const totalRecords = fix.componentInstance.grid.totalRecords.toString();
4349+
const paginationContent = fix.debugElement.query(By.css('.igx-grid__footer > h2')).nativeElement;
4350+
const paginationText = paginationContent.textContent.trim();
4351+
4352+
expect(paginationText).toEqual(totalRecords);
4353+
});
4354+
});
43084355
});
43094356

43104357
@Component({
@@ -4453,6 +4500,19 @@ export class IgxGridColumnPercentageWidthComponent extends IgxGridDefaultRenderi
44534500
}
44544501
}
44554502

4503+
@Component({
4504+
template:
4505+
`<div>
4506+
<igx-grid #grid [data]="data" [displayDensity]="'compact'" [autoGenerate]="true"
4507+
[paging]="true" [perPage]="5">
4508+
<igx-grid-footer>
4509+
Custom content
4510+
</igx-grid-footer>
4511+
</igx-grid>
4512+
</div>`
4513+
})
4514+
export class IgxGridWithCustomFooterComponent extends IgxGridTestComponent {
4515+
}
44564516
@Component({
44574517
template:
44584518
`<div [style.width.px]="outerWidth" [style.height.px]="outerHeight">
@@ -5011,3 +5071,19 @@ export class IgxGridInsideIgxTabsComponent {
50115071
this.data = data;
50125072
}
50135073
}
5074+
5075+
@Component({
5076+
template: `
5077+
<igx-grid #grid [data]="data"
5078+
[paging]="true" [paginationTemplate]="pager">
5079+
</igx-grid>
5080+
<ng-template #pager let-grid>
5081+
<h2>{{grid.totalRecords}}</h2>
5082+
</ng-template>
5083+
`
5084+
})
5085+
export class IgxGridWithCustomPaginationTemplateComponent {
5086+
public data = SampleTestData.foodProductData();
5087+
@ViewChild('grid', { read: IgxGridComponent, static: true })
5088+
public grid: IgxGridComponent;
5089+
}

0 commit comments

Comments
 (0)