Skip to content

Commit

Permalink
sample(esf): add hier-grid esf LOD sample
Browse files Browse the repository at this point in the history
  • Loading branch information
tachojelev committed Aug 13, 2019
1 parent 9ba15c7 commit 5dac9ed
Show file tree
Hide file tree
Showing 8 changed files with 139 additions and 1 deletion.
15 changes: 15 additions & 0 deletions live-editing/configs/HierarchicalGridConfigGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { HGridCustomKBNavigationComponent } from "../../src/app/hierarchical-gri
import { HGridDisplayDensitySampleComponent } from "../../src/app/hierarchical-grid/hierarchical-grid-display-density/hierarchical-grid-density.component";
import { HGridEditingStyleComponent } from "../../src/app/hierarchical-grid/hierarchical-grid-editing-style/hierarchical-grid-editing-style.component";
import { HGridEditingSampleComponent } from "../../src/app/hierarchical-grid/hierarchical-grid-editing/hierarchical-grid-editing.component";
import { HierarchicalGridExcelStyleFilteringLoadOnDemandComponent } from "../../src/app/hierarchical-grid/hierarchical-grid-excel-style-filtering-load-on-demand/hierarchical-grid-excel-style-filtering-load-on-demand.component";
import {
HGridExcelStyleFilteringSample1Component
} from "../../src/app/hierarchical-grid/hierarchical-grid-excel-style-filtering-sample-1/hierarchical-grid-excel-style-filtering-sample-1.component";
Expand Down Expand Up @@ -68,6 +69,7 @@ import { HGridToolbarCustomSampleComponent } from "../../src/app/hierarchical-gr
import { HGridToolbarOptionsSampleComponent } from "../../src/app/hierarchical-grid/hierarchical-grid-toolbar/hierarchical-grid-toolbar-options.component";
import { HGridToolbarTitleSampleComponent } from "../../src/app/hierarchical-grid/hierarchical-grid-toolbar/hierarchical-grid-toolbar-title.component";
import { RemoteLoDService } from "../../src/app/hierarchical-grid/services/remote-lod.service";
import { RemoteValuesService } from "../../src/app/hierarchical-grid/hierarchical-grid-excel-style-filtering-load-on-demand/remoteValues.service";
import { AppModuleConfig } from "./core/AppModuleConfig";
import { Config } from "./core/Config";
import { IConfigGenerator } from "./core/IConfigGenerator";
Expand Down Expand Up @@ -441,6 +443,19 @@ export class HierarchicalGridConfigGenerator implements IConfigGenerator {
component: HierarchicalGridLoDSampleComponent
}));

// Hierarchical Grid Excel Style Filtering Load On Demand Sample
configs.push(new Config({
additionalFiles: ["/src/app/hierarchical-grid/hierarchical-grid-excel-style-filtering-load-on-demand/remoteValues.service.ts",
"/src/app/hierarchical-grid/data.ts"],
appModuleConfig: new AppModuleConfig({
imports: [IgxHierarchicalGridModule, HierarchicalGridExcelStyleFilteringLoadOnDemandComponent, RemoteValuesService],
ngDeclarations: [HierarchicalGridExcelStyleFilteringLoadOnDemandComponent],
ngImports: [IgxHierarchicalGridModule],
ngProviders: [RemoteValuesService]
}),
component: HierarchicalGridExcelStyleFilteringLoadOnDemandComponent
}));

configs.push(new Config({
additionalFiles: ["/src/app/data/files.data.ts"],
appModuleConfig: new AppModuleConfig({
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<div class="wrapper">
<igx-hierarchical-grid #hierarchicalGrid [primaryKey]="'Artist'" [data]="localdata" height="750px" [displayDensity]="'cosy'"
[showToolbar]="true" [columnHiding]="true" [columnPinning]="true" [autoGenerate]="false"
[allowFiltering]="true" [filterMode]="'excelStyleFilter'"
[uniqueColumnValuesStrategy]="singersColumnValuesStrategy">
<igx-column field="Photo" [filterable]="false">
<ng-template igxCell let-cell="cell">
<div class="cell__inner">
<img [src]="cell.value" class="photo" />
</div>
</ng-template>
</igx-column>
<igx-column field="Artist" [sortable]="true" [movable]="true"></igx-column>
<igx-column field="Debut" [sortable]="true" [movable]="true" [dataType]="'number'"></igx-column>
<igx-column field="GrammyNominations" header="Grammy Nominations" [dataType]="'number'" [sortable]="true" [movable]="true"></igx-column>
<igx-column field="GrammyAwards" header="Grammy Awards" [dataType]="'number'" [sortable]="true" [movable]="true"></igx-column>
<igx-row-island [key]="'Albums'" [primaryKey]="'Album'" [autoGenerate]="false" [allowFiltering]="true" [filterMode]="'excelStyleFilter'"
[uniqueColumnValuesStrategy]="albumsColumnValuesStrategy">
<igx-column field="Album" [sortable]="true" [movable]="true"></igx-column>
<igx-column field="LaunchDate" header="Launch Date" [sortable]="true" [movable]="true" [dataType]="'date'"></igx-column>
<igx-column field="BillboardReview" header="Billboard Review" [sortable]="true" [movable]="true" [dataType]="'number'"></igx-column>
<igx-column field="USBillboard200" header="US Billboard 200" [sortable]="true" [movable]="true" [dataType]="'number'"></igx-column>
<igx-row-island [key]="'Songs'" [primaryKey]="'Title'" [autoGenerate]="false" >
<igx-column field="Number" header="No."></igx-column>
<igx-column field="Title"></igx-column>
<igx-column field="Released" dataType="date"></igx-column>
<igx-column field="Genre"></igx-column>
</igx-row-island>
</igx-row-island>
</igx-hierarchical-grid>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.wrapper {
margin: 16px;
}

.photo {
vertical-align: middle;
max-height: 40px;
}
.cell__inner {
margin: 1px auto 1px auto;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { Component, OnInit } from "@angular/core";
import { IFilteringExpressionsTree, IgxColumnComponent } from "igniteui-angular";
import { RemoteValuesService } from "./remoteValues.service";

@Component({
selector: "app-hierarchical-grid-excel-style-filtering-load-on-demand",
templateUrl: "./hierarchical-grid-excel-style-filtering-load-on-demand.component.html",
styleUrls: ["./hierarchical-grid-excel-style-filtering-load-on-demand.component.scss"],
providers: [RemoteValuesService]
})
export class HierarchicalGridExcelStyleFilteringLoadOnDemandComponent implements OnInit {

public localdata: any[];

constructor(private remoteValuesService: RemoteValuesService) { }

public singersColumnValuesStrategy = (column: IgxColumnComponent,
columnExprTree: IFilteringExpressionsTree,
done: (uniqueValues: any[]) => void) => {
// Get specific column data for the singers.
this.remoteValuesService.getColumnData(
null, "Singers", column, columnExprTree, uniqueValues => done(uniqueValues));
}

public albumsColumnValuesStrategy = (column: IgxColumnComponent,
columnExprTree: IFilteringExpressionsTree,
done: (uniqueValues: any[]) => void) => {
// Get specific column data for the albums of a specific singer.
const parentRowId = (column.grid as any).foreignKey;
this.remoteValuesService.getColumnData(
parentRowId, "Albums", column, columnExprTree, uniqueValues => done(uniqueValues));
}

public ngOnInit() {
this.localdata = this.remoteValuesService.getSingersData();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { Injectable } from "@angular/core";
import { FilteringStrategy, IFilteringExpressionsTree, IgxColumnComponent } from "igniteui-angular";
import { SINGERS } from "../data";

@Injectable()
export class RemoteValuesService {
private _filteringStrategy = new FilteringStrategy();

public getSingersData() {
return SINGERS;
}

public getColumnData(parentId: any, key: string,
column: IgxColumnComponent,
columnExprTree: IFilteringExpressionsTree,
done: (colVals: any[]) => void) {
setTimeout(() => {
let filteredData = [];

if (!parentId) {
// Generate unique column values for the singers.
filteredData = this._filteringStrategy.filter(this.getSingersData(), columnExprTree);
} else if (key === "Albums") {
// Generate unique column values for the albums of a specific singer.
const singer = this.getSingersData().find((rec) => rec.Artist === parentId);
const albums = singer ? (singer.Albums ? singer.Albums : []) : [];
filteredData = this._filteringStrategy.filter(albums, columnExprTree);
}

const columnValues = filteredData.map(record => record[column.field]);
done(columnValues);
}, 1000);
}
}
1 change: 1 addition & 0 deletions src/app/hierarchical-grid/hierarchical-grid-routes-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const hierarchicalGridRoutesData = {
"hierarchical-grid-excel-style-filtering-sample-1": { displayName: "Hierarchical Grid Excel Style Filtering", parentName: "Hierarchical Grid" },
"hierarchical-grid-excel-style-filtering-sample-2": { displayName: "Hierarchical Grid Excel Style Filtering Operations", parentName: "Hierarchical Grid" },
"hierarchical-grid-excel-style-filtering-sample-3": { displayName: "Hierarchical Grid Excel Style Filtering Templates", parentName: "Hierarchical Grid" },
"hierarchical-grid-excel-style-filtering-load-on-demand": { displayName: "Hierarchical Grid Excel Style Filtering Load On Demand", parentName: "Hierarchical Grid" },
"hierarchical-grid-custom-filtering": { displayName: "Hierarchical Grid Custom Filtering", parentName: "Hierarchical Grid" },
"hierarchical-grid-sorting": { displayName: "Hierarchical Grid Sorting", parentName: "Hierarchical Grid" },
"hierarchical-grid-sorting-styling": { displayName: "Hierarchical Grid Sorting Styling", parentName: "Hierarchical Grid" },
Expand Down
7 changes: 7 additions & 0 deletions src/app/hierarchical-grid/hierarchical-grid-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { HGridCustomKBNavigationComponent } from "./hierarchical-grid-custom-kb-
import { HGridDisplayDensitySampleComponent } from "./hierarchical-grid-display-density/hierarchical-grid-density.component";
import { HGridEditingStyleComponent } from "./hierarchical-grid-editing-style/hierarchical-grid-editing-style.component";
import { HGridEditingSampleComponent } from "./hierarchical-grid-editing/hierarchical-grid-editing.component";
import { HierarchicalGridExcelStyleFilteringLoadOnDemandComponent } from "./hierarchical-grid-excel-style-filtering-load-on-demand/hierarchical-grid-excel-style-filtering-load-on-demand.component";
import {
HGridExcelStyleFilteringSample1Component
} from "./hierarchical-grid-excel-style-filtering-sample-1/hierarchical-grid-excel-style-filtering-sample-1.component";
Expand Down Expand Up @@ -82,6 +83,12 @@ export const hierarchicalGridRoutes: Routes = [
data: hierarchicalGridRoutesData["hierarchical-grid-excel-style-filtering-sample-3"],
path: "hierarchical-grid-excel-style-filtering-sample-3"
},
{
component: HierarchicalGridExcelStyleFilteringLoadOnDemandComponent,
// tslint:disable-next-line:no-string-literal
data: hierarchicalGridRoutesData["hierarchical-grid-excel-style-filtering-load-on-demand"],
path: "hierarchical-grid-excel-style-filtering-load-on-demand"
},
{
component: HGridCustomFilteringSampleComponent,
// tslint:disable-next-line:no-string-literal
Expand Down
4 changes: 3 additions & 1 deletion src/app/hierarchical-grid/hierarchical-grid.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { HGridCustomKBNavigationComponent } from "./hierarchical-grid-custom-kb-
import { HGridDisplayDensitySampleComponent } from "./hierarchical-grid-display-density/hierarchical-grid-density.component";
import { HGridEditingStyleComponent } from "./hierarchical-grid-editing-style/hierarchical-grid-editing-style.component";
import { HGridEditingSampleComponent } from "./hierarchical-grid-editing/hierarchical-grid-editing.component";
import { HierarchicalGridExcelStyleFilteringLoadOnDemandComponent } from "./hierarchical-grid-excel-style-filtering-load-on-demand/hierarchical-grid-excel-style-filtering-load-on-demand.component";
import { HGridExcelStyleFilteringSample1Component } from "./hierarchical-grid-excel-style-filtering-sample-1/hierarchical-grid-excel-style-filtering-sample-1.component";
import { HGridExcelStyleFilteringSample2Component } from "./hierarchical-grid-excel-style-filtering-sample-2/hierarchical-grid-excel-style-filtering-sample-2.component";
import { HGridExcelStyleFilteringSample3Component } from "./hierarchical-grid-excel-style-filtering-sample-3/hierarchical-grid-excel-style-filtering-sample-3.component";
Expand Down Expand Up @@ -93,7 +94,8 @@ import { HGridToolbarTitleSampleComponent } from "./hierarchical-grid-toolbar/hi
HierarchicalGridColumnHidingToolbarStyleComponent,
HGridMultiHeaderTemplateSampleComponent,
HierarchicalGridToolbarStyleComponent,
HierarchicalGridFilteringStyleComponent
HierarchicalGridFilteringStyleComponent,
HierarchicalGridExcelStyleFilteringLoadOnDemandComponent
],
imports: [
CommonModule,
Expand Down

0 comments on commit 5dac9ed

Please sign in to comment.