Skip to content

Commit 155eda9

Browse files
committed
feat(esf): make corrections on POC #5448
1 parent 8cab60a commit 155eda9

File tree

7 files changed

+46
-30
lines changed

7 files changed

+46
-30
lines changed

projects/igniteui-angular/src/lib/grids/filtering/excel-style/excel-style-search.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@
3939

4040
<ng-template igxDataLoading>
4141
<div style="display: flex; align-items: center;" class="esf-loading-indicator">
42-
<ng-container *ngTemplateOutlet="grid.esfLoadingIndicatorTemplate ? grid.esfLoadingIndicatorTemplate : defaultEsfLoadingIndicatorTemplate">
42+
<ng-container *ngTemplateOutlet="valuesLoadingTemplate">
4343
</ng-container>
4444
</div>
4545
</ng-template>
4646
</igx-list>
4747

48-
<ng-template #defaultEsfLoadingIndicatorTemplate>
48+
<ng-template #defaultExcelStyleLoadingValuesTemplate>
4949
<igx-circular-bar [indeterminate]="true">
5050
</igx-circular-bar>
5151
</ng-template>

projects/igniteui-angular/src/lib/grids/filtering/excel-style/excel-style-search.component.ts

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,24 @@ import {
44
ChangeDetectionStrategy,
55
Input,
66
ViewChild,
7-
ChangeDetectorRef
7+
ChangeDetectorRef,
8+
TemplateRef,
9+
Directive
810
} from '@angular/core';
911
import { IgxColumnComponent } from '../../column.component';
10-
import { IgxFilterOptions } from '../../../directives/filter/filter.directive';
1112
import { IChangeCheckboxEventArgs } from '../../../checkbox/checkbox.component';
1213
import { IgxInputDirective } from '../../../directives/input/input.directive';
1314
import { DisplayDensity } from '../../../core/density';
1415
import { IgxForOfDirective } from '../../../directives/for-of/for_of.directive';
1516
import { FilterListItem } from './grid.excel-style-filtering.component';
1617

18+
@Directive({
19+
selector: '[igxExcelStyleLoadingValuesTemplate]'
20+
})
21+
export class IgxExcelStyleLoadingValuesTemplateDirective {
22+
constructor(public template: TemplateRef<any>) {}
23+
}
24+
1725
/**
1826
* @hidden
1927
*/
@@ -56,6 +64,17 @@ export class IgxExcelStyleSearchComponent implements AfterViewInit {
5664
@ViewChild(IgxForOfDirective, { static: true })
5765
protected virtDir: IgxForOfDirective<any>;
5866

67+
@ViewChild('defaultExcelStyleLoadingValuesTemplate', { read: TemplateRef, static: true })
68+
protected defaultExcelStyleLoadingValuesTemplate: TemplateRef<any>;
69+
70+
public get valuesLoadingTemplate() {
71+
if (this.grid.excelStyleLoadingValuesTemplateDirective) {
72+
return this.grid.excelStyleLoadingValuesTemplateDirective.template;
73+
} else {
74+
return this.defaultExcelStyleLoadingValuesTemplate;
75+
}
76+
}
77+
5978
constructor(private _cdr: ChangeDetectorRef) { }
6079

6180
public ngAfterViewInit() {

projects/igniteui-angular/src/lib/grids/filtering/excel-style/grid.excel-style-filtering.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ export class IgxGridExcelStyleFilteringComponent implements OnDestroy, AfterView
332332
}
333333

334334
public populateColumnData() {
335-
if (this.grid.loadColumnValuesOnDemand) {
335+
if (this.grid.loadExcelStyleUniqueValuesOnDemand) {
336336
this.loadValuesOnDemand();
337337
} else {
338338
this.loadValuesFromGridData();
@@ -341,7 +341,7 @@ export class IgxGridExcelStyleFilteringComponent implements OnDestroy, AfterView
341341

342342
private loadValuesOnDemand() {
343343
this.excelStyleSearch.isLoading = true;
344-
this.grid.loadColumnValuesOnDemand(this.column.field, (columnUniqueValues: any[]) => {
344+
this.grid.loadExcelStyleUniqueValuesOnDemand(this.column, (columnUniqueValues: any[]) => {
345345
if (this.column.dataType === DataType.Date) {
346346
this.uniqueValues = Array.from(new Set(columnUniqueValues.map(val => val ? val.toDateString() : val)));
347347
this.generateFilterValues(true);

projects/igniteui-angular/src/lib/grids/filtering/excel-style/grid.excel-style-filtering.module.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { NgModule } from '@angular/core';
22
import { CommonModule } from '@angular/common';
3+
import { IgxExcelStyleLoadingValuesTemplateDirective } from './excel-style-search.component';
34
import {
45
IgxGridExcelStyleFilteringComponent,
56
IgxExcelStyleSortingTemplateDirective,
@@ -47,6 +48,7 @@ import { IgxProgressBarModule } from '../../../progressbar/progressbar.component
4748
IgxExcelStyleHidingTemplateDirective,
4849
IgxExcelStyleMovingTemplateDirective,
4950
IgxExcelStylePinningTemplateDirective,
51+
IgxExcelStyleLoadingValuesTemplateDirective,
5052
IgxExcelStyleSearchFilterPipe
5153
],
5254
exports: [
@@ -55,6 +57,7 @@ import { IgxProgressBarModule } from '../../../progressbar/progressbar.component
5557
IgxExcelStyleHidingTemplateDirective,
5658
IgxExcelStyleMovingTemplateDirective,
5759
IgxExcelStylePinningTemplateDirective,
60+
IgxExcelStyleLoadingValuesTemplateDirective,
5861
IgxExcelStyleDateExpressionComponent
5962
],
6063
imports: [

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

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ import { IgxSummaryRowComponent } from './summaries/summary-row.component';
8080
import { IgxGridSelectionService, GridSelectionRange, IgxGridCRUDService, IgxRow, IgxCell } from '../core/grid-selection';
8181
import { DragScrollDirection } from './drag-select.directive';
8282
import { ICachedViewLoadedEventArgs, IgxTemplateOutletDirective } from '../directives/template-outlet/template_outlet.directive';
83+
import { IgxExcelStyleLoadingValuesTemplateDirective } from './filtering/excel-style/excel-style-search.component';
8384
import {
8485
IgxExcelStyleSortingTemplateDirective,
8586
IgxExcelStylePinningTemplateDirective,
@@ -1002,17 +1003,7 @@ export abstract class IgxGridBaseComponent extends DisplayDensityBase implements
10021003
}
10031004

10041005
@Input()
1005-
public get esfLoadingIndicatorTemplate(): TemplateRef<any> {
1006-
return this._esfLoadingIndicatorTemplate;
1007-
}
1008-
1009-
public set esfLoadingIndicatorTemplate(value: TemplateRef<any>) {
1010-
this._esfLoadingIndicatorTemplate = value;
1011-
this.cdr.markForCheck();
1012-
}
1013-
1014-
@Input()
1015-
public loadColumnValuesOnDemand: (field: string, done: (values: any[]) => void) => void;
1006+
public loadExcelStyleUniqueValuesOnDemand: (field: string, done: (values: any[]) => void) => void;
10161007

10171008
/**
10181009
* Emitted when `IgxGridCellComponent` is clicked. Returns the `IgxGridCellComponent`.
@@ -1582,6 +1573,11 @@ export abstract class IgxGridBaseComponent extends DisplayDensityBase implements
15821573
@ContentChild(IgxExcelStylePinningTemplateDirective, { read: IgxExcelStylePinningTemplateDirective, static: true })
15831574
public excelStylePinningTemplateDirective: IgxExcelStylePinningTemplateDirective;
15841575

1576+
/**
1577+
*@hidden
1578+
*/
1579+
@ContentChild(IgxExcelStyleLoadingValuesTemplateDirective, { read: IgxExcelStyleLoadingValuesTemplateDirective, static: true })
1580+
public excelStyleLoadingValuesTemplateDirective: IgxExcelStyleLoadingValuesTemplateDirective;
15851581

15861582
/**
15871583
* @hidden

src/app/grid-esf-load-on-demand/grid-esf-load-on-demand.component.html

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,23 @@
88
<div class="density-chooser">
99
<igx-buttongroup [values]="displayDensities" (onSelect)="selectDensity($event)"></igx-buttongroup>
1010
</div>
11-
<igx-grid #grid1 [data]="data" [displayDensity]="density" [showToolbar]="true"
12-
[columnHiding]="true" [allowFiltering]="true" [rowSelectable]="true"
13-
[filterMode]="'excelStyleFilter'" [width]="'900px'"
14-
[height]="'800px'" [style.zIndex]="'1'"
11+
<igx-grid #grid1 [data]="data" [width]="'900px'" [height]="'800px'" [displayDensity]="density"
12+
[showToolbar]="true" [columnHiding]="true" [allowFiltering]="true" [rowSelectable]="true"
13+
[filterMode]="'excelStyleFilter'"
1514

16-
[loadColumnValuesOnDemand]="loadColumnValues"
17-
[esfLoadingIndicatorTemplate]="loadTemplate"
15+
[loadExcelStyleUniqueValuesOnDemand]="loadColumnValues"
1816
>
1917

2018
<igx-column [field]="'ID'" [filterable]="true" [sortable]="true" [movable]="true" [dataType]="'string'"></igx-column>
2119
<igx-column [field]="'CompanyName'" [filterable]="true" [sortable]="true" [movable]="true" [dataType]="'string'"></igx-column>
2220
<igx-column [field]="'Employees'" [filterable]="true" [sortable]="true" [movable]="true" [dataType]="'number'"></igx-column>
2321
<igx-column [field]="'Contract'" [filterable]="true" [sortable]="true" [movable]="true" [dataType]="'boolean'"></igx-column>
2422
<igx-column [field]="'DateCreated'" [filterable]="true" [sortable]="true" [movable]="true" [dataType]="'date'"></igx-column>
23+
24+
<!-- <ng-template igxExcelStyleLoadingValuesTemplate>
25+
Loading ...
26+
</ng-template> -->
2527
</igx-grid>
2628
</div>
2729
</div>
2830
</div>
29-
30-
<ng-template #loadTemplate>
31-
Loading ...
32-
</ng-template>

src/app/grid-esf-load-on-demand/grid-esf-load-on-demand.component.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Component, ViewChild, OnInit } from '@angular/core';
2-
import { IgxGridComponent } from 'igniteui-angular';
2+
import { IgxGridComponent, IgxColumnComponent } from 'igniteui-angular';
33
import { SAMPLE_DATA } from '../shared/sample-data';
44
import { GridESFLoadOnDemandService } from './grid-esf-load-on-demand.service';
55

@@ -19,8 +19,8 @@ export class GridEsfLoadOnDemandComponent implements OnInit {
1919
@ViewChild('grid1', { static: true })
2020
public grid1: IgxGridComponent;
2121

22-
public loadColumnValues = (columnField: string, done: (uniqueValues: string[]) => void) => {
23-
this.esfService.getData(columnField, uniqueValues => done(uniqueValues));
22+
public loadColumnValues = (column: IgxColumnComponent, done: (uniqueValues: string[]) => void) => {
23+
this.esfService.getData(column.field, uniqueValues => done(uniqueValues));
2424
}
2525

2626
public ngOnInit(): void {

0 commit comments

Comments
 (0)