Skip to content

Commit 3f939b3

Browse files
committed
Merge branch 'vNext' into dmdimitrov/issue1613-vNext
2 parents 3d8fbde + 56df85f commit 3f939b3

20 files changed

+488
-380
lines changed

live-editing/configs/GridConfigGenerator.ts

+33-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ import {
2626
IgxSnackbarModule,
2727
IgxSwitchModule,
2828
IgxToastModule,
29-
IgxTooltipModule
29+
IgxTooltipModule,
30+
IgxTabsModule
3031
} from "igniteui-angular";
3132
// tslint:disable-next-line: max-line-length
3233
import { IgxSparklineCoreModule} from "igniteui-angular-charts/ES5/igx-sparkline-core-module";
@@ -78,6 +79,8 @@ import { GridCustomFilteringComponent } from "../../src/app/grid/grid-custom-fil
7879
import {
7980
GridCustomKBNavigationComponent
8081
} from "../../src/app/grid/grid-custom-kb-navigation/grid-custom-kb-navigation-sample.component";
82+
// tslint:disable-next-line: max-line-length
83+
import { CustomRemotePagingGridSample } from "../../src/app/grid/grid-custom-remote-paging-sample/custom-remote-paging-sample.component";
8184
import {
8285
GridCustomSummariesSelection
8386
} from "../../src/app/grid/grid-custom-summaries-selection/grid-custom-summaries-selection.component";
@@ -93,6 +96,7 @@ import {
9396
} from "../../src/app/grid/grid-editing-style-sample/grid-editing-style-sample.component";
9497
import {
9598
GridExcelStyleFilteringLoadOnDemandComponent
99+
// tslint:disable-next-line: max-line-length
96100
} from "../../src/app/grid/grid-excel-style-filtering-load-on-demand/grid-excel-style-filtering-load-on-demand.component";
97101
import { RemoteValuesService } from "../../src/app/grid/grid-excel-style-filtering-load-on-demand/remoteValues.service";
98102
import {
@@ -209,6 +213,8 @@ import { RemoteServiceVirt } from "../../src/app/grid/services/remoteService";
209213
import { AppModuleConfig } from "./core/AppModuleConfig";
210214
import { Config } from "./core/Config";
211215
import { IConfigGenerator } from "./core/IConfigGenerator";
216+
import { GridMasterDetailSampleComponent } from '../../src/app/grid/grid-master-detail/grid-master-detail.component';
217+
import { IgxCategoryChartModule } from 'igniteui-angular-charts/ES5/igx-category-chart-module';
212218

213219
export class GridConfigGenerator implements IConfigGenerator {
214220
public generateConfigs(): Config[] {
@@ -546,6 +552,20 @@ export class GridConfigGenerator implements IConfigGenerator {
546552
})
547553
}));
548554

555+
// master-detail sample
556+
configs.push(new Config({
557+
component: GridMasterDetailSampleComponent,
558+
additionalFiles: ["/src/app/grid-crm/grid-crm/data.ts"],
559+
additionalDependencies: ["igniteui-angular-charts"],
560+
appModuleConfig: new AppModuleConfig({
561+
imports: [GridMasterDetailSampleComponent, IgxGridModule, IgxCategoryChartModule,
562+
IgxAvatarModule, IgxTabsModule],
563+
ngDeclarations: [GridMasterDetailSampleComponent],
564+
ngImports: [IgxGridModule, IgxIconModule],
565+
ngProviders: []
566+
})
567+
}));
568+
549569
configs.push(new Config({
550570
component: GridMovingStyledSampleComponent,
551571
additionalFiles: ["/src/app/grid/services/financialData.ts"],
@@ -681,6 +701,18 @@ export class GridConfigGenerator implements IConfigGenerator {
681701
})
682702
}));
683703

704+
configs.push(new Config({
705+
component: CustomRemotePagingGridSample,
706+
additionalFiles: ["/src/app/grid/services/remotePagingService.ts"],
707+
appModuleConfig: new AppModuleConfig({
708+
imports: [CustomRemotePagingGridSample, IgxGridModule, RouterModule, HttpClientModule,
709+
RemotePagingService, IgxSelectModule],
710+
ngDeclarations: [CustomRemotePagingGridSample],
711+
ngImports: ["RouterModule.forRoot([])", IgxGridModule, HttpClientModule, IgxSelectModule],
712+
ngProviders: [RemotePagingService]
713+
})
714+
}));
715+
684716
configs.push(new Config({
685717
component: GridDisplayDensitySampleComponent,
686718
additionalFiles: ["/src/app/data/invoiceData.ts"],

package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<div class="grid__wrapper">
2+
<igx-grid #grid1 [data]="data | async" width="100%" height="540px" [paging]="true" [perPage]="perPage" [paginationTemplate]="customPager">
3+
<igx-column field="ID"></igx-column>
4+
<igx-column field="ProductName"></igx-column>
5+
<igx-column field="QuantityPerUnit"></igx-column>
6+
<igx-column field="SupplierName"></igx-column>
7+
<igx-column field="UnitsInStock"></igx-column>
8+
<igx-column field="Rating"></igx-column>
9+
</igx-grid>
10+
<ng-template #customPager let-api>
11+
<div class="igx-grid__footer">
12+
<div id="numberPager" class="igx-paginator" style="justify-content: center;">
13+
<button [disabled]="firstPage" (click)="previousPage()" igxButton="flat">
14+
PREV
15+
</button>
16+
<span *ngIf="shouldShowFirstPage" (click)="paginate(0)">
17+
<a class="pageNavLinks" [routerLink]=''>{{1}}</a> <span class="pageNavLinks">...</span>
18+
</span>
19+
<span *ngFor="let item of pages" (click)="paginate(item)">
20+
<a class="pageNavLinks {{activePage(item)}}" [routerLink]=''>{{item + 1}}</a>
21+
</span>
22+
<span *ngIf="shouldShowLastPage" (click)="paginate(totalPages - 1)">
23+
<span class="pageNavLinks">...</span> <a class="pageNavLinks" [routerLink]=''>{{ totalPages }}</a>
24+
</span>
25+
<button [disabled]="lastPage" (click)="nextPage()" igxButton="flat">
26+
NEXT
27+
</button>
28+
</div>
29+
</div>
30+
</ng-template>
31+
</div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
.grid__wrapper {
2+
margin: 0 16px;
3+
padding-top: 10px;
4+
}
5+
6+
.pageNavLinks {
7+
text-decoration: none;
8+
font-size: 10.5pt;
9+
color: #989898;
10+
}
11+
12+
.activePage {
13+
font-size: 11.5pt;
14+
font-weight: bold;
15+
}
16+
17+
.igx-input-group__input {
18+
display: inline;
19+
}
20+
21+
#numberPager > * {
22+
margin-left: .5rem;
23+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
import { AfterViewInit, Component, OnDestroy, OnInit, TemplateRef, ViewChild, ViewEncapsulation } from "@angular/core";
2+
import { IgxGridComponent } from "igniteui-angular";
3+
import { Observable } from "rxjs";
4+
import { RemotePagingService } from "../services/remotePagingService";
5+
@Component({
6+
encapsulation: ViewEncapsulation.None,
7+
providers: [RemotePagingService],
8+
selector: "custom-remote-paging-grid-sample",
9+
styleUrls: ["./custom-remote-paging-sample.component.scss"],
10+
templateUrl: "./custom-remote-paging-sample.component.html"
11+
})
12+
export class CustomRemotePagingGridSample implements OnInit, AfterViewInit, OnDestroy {
13+
14+
public page = 0;
15+
public lastPage = false;
16+
public firstPage = true;
17+
public totalPages: number = 1;
18+
public totalCount = 0;
19+
public pages = [];
20+
public title = "gridPaging";
21+
public data: Observable<any[]>;
22+
23+
@ViewChild("customPager", { read: TemplateRef, static: true }) public remotePager: TemplateRef<any>;
24+
@ViewChild("grid1", { static: true }) public grid1: IgxGridComponent;
25+
26+
private visibleElements = 5;
27+
private _perPage = 10;
28+
private _dataLengthSubscriber;
29+
30+
constructor(
31+
private remoteService: RemotePagingService) {
32+
}
33+
34+
public get perPage(): number {
35+
return this._perPage;
36+
}
37+
38+
public set perPage(val: number) {
39+
this._perPage = val;
40+
this.paginate(0, true);
41+
}
42+
43+
public get shouldShowLastPage() {
44+
return this.pages[this.pages.length - 1] !== this.totalPages - 1;
45+
}
46+
47+
public get shouldShowFirstPage() {
48+
return this.pages[0] !== 0;
49+
}
50+
51+
public ngOnInit() {
52+
this.data = this.remoteService.remoteData.asObservable();
53+
54+
this._dataLengthSubscriber = this.remoteService.getDataLength().subscribe((data) => {
55+
this.totalCount = data;
56+
this.totalPages = Math.ceil(data / this.perPage);
57+
this.buttonDeselection(this.page, this.totalPages);
58+
this.grid1.isLoading = false;
59+
this.setNumberOfPagingItems(this.page, this.totalPages);
60+
});
61+
62+
}
63+
64+
public ngOnDestroy() {
65+
if (this._dataLengthSubscriber) {
66+
this._dataLengthSubscriber.unsubscribe();
67+
}
68+
}
69+
70+
public ngAfterViewInit() {
71+
this.grid1.isLoading = true;
72+
this.remoteService.getData(0, this.perPage);
73+
}
74+
75+
public nextPage() {
76+
this.firstPage = false;
77+
this.page++;
78+
const skip = this.page * this.perPage;
79+
const top = this.perPage;
80+
this.remoteService.getData(skip, top);
81+
if (this.page + 1 >= this.totalPages) {
82+
this.lastPage = true;
83+
}
84+
this.setNumberOfPagingItems(this.page, this.totalPages);
85+
}
86+
87+
public previousPage() {
88+
this.lastPage = false;
89+
this.page--;
90+
const skip = this.page * this.perPage;
91+
const top = this.perPage;
92+
this.remoteService.getData(skip, top);
93+
if (this.page <= 0) {
94+
this.firstPage = true;
95+
}
96+
this.setNumberOfPagingItems(this.page, this.totalPages);
97+
}
98+
99+
public paginate(page: number, recalc = false) {
100+
this.page = page;
101+
const skip = this.page * this.perPage;
102+
const top = this.perPage;
103+
if (recalc) {
104+
this.totalPages = Math.ceil(this.totalCount / this.perPage);
105+
}
106+
this.setNumberOfPagingItems(this.page, this.totalPages);
107+
this.remoteService.getData(skip, top);
108+
this.buttonDeselection(this.page, this.totalPages);
109+
}
110+
111+
public buttonDeselection(page: number, totalPages: number) {
112+
if (totalPages === 1) {
113+
this.lastPage = true;
114+
this.firstPage = true;
115+
} else if (page + 1 >= totalPages) {
116+
this.lastPage = true;
117+
this.firstPage = false;
118+
} else if (page !== 0 && page !== totalPages) {
119+
this.lastPage = false;
120+
this.firstPage = false;
121+
} else {
122+
this.lastPage = false;
123+
this.firstPage = true;
124+
}
125+
}
126+
127+
public activePage(page) {
128+
return page === this.page ? "activePage" : "";
129+
}
130+
131+
public setNumberOfPagingItems(currentPage, totalPages) {
132+
if (currentPage > this.pages[0] && currentPage < this.pages[this.pages.length]) {
133+
return;
134+
}
135+
if (this.pages.length === 0) {
136+
const lastPage = (currentPage + this.visibleElements) <= totalPages ?
137+
currentPage + this.visibleElements : totalPages;
138+
for (let item = 0; item < lastPage; item++) {
139+
this.pages.push(item);
140+
}
141+
return;
142+
}
143+
if (currentPage <= this.pages[0]) {
144+
this.pages = [];
145+
let firstPage = currentPage - 1 < 0 ? 0 : currentPage - 1;
146+
firstPage = firstPage > totalPages - this.visibleElements ?
147+
totalPages - this.visibleElements : firstPage;
148+
firstPage = firstPage >= 0 ? firstPage : 0;
149+
const lastPage = (firstPage + this.visibleElements) <= totalPages ?
150+
firstPage + this.visibleElements : totalPages;
151+
for (let item = firstPage; item < lastPage; item++) {
152+
this.pages.push(item);
153+
}
154+
155+
} else if (currentPage >= this.pages[this.pages.length - 1]) {
156+
this.pages = [];
157+
let firstPage = currentPage > totalPages - this.visibleElements ?
158+
totalPages - this.visibleElements : currentPage - 1;
159+
firstPage = firstPage >= 0 ? firstPage : 0;
160+
const lastPage = (firstPage + this.visibleElements) <= totalPages ?
161+
firstPage + this.visibleElements : totalPages;
162+
for (let item = firstPage; item < lastPage; item++) {
163+
this.pages.push(item);
164+
}
165+
}
166+
}
167+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<igx-grid displayDensity="cosy" [data]="data" [autoGenerate]="false" [height]="'600px'" [width]="'738px'">
2+
<igx-column field="name" header="Name" width="150px"></igx-column>
3+
<igx-column field="position" header="Position" width="200px"></igx-column>
4+
<igx-column field="company" header="Company" width="130px"></igx-column>
5+
<igx-column field="email" header="Email" width="240px"></igx-column>
6+
<ng-template igxGridDetail let-dataItem>
7+
<div style='width:100%;'>
8+
<igx-tabs>
9+
<igx-tabs-group label="Details">
10+
<div class='tabContent'>
11+
<igx-avatar src="https://www.infragistics.com/angular-demos/{{dataItem.avatar}}" roundShape="false" size="large"></igx-avatar>
12+
<div class='tabInnerContent'>
13+
<div>
14+
<div><span class='categoryStyle'>Country:</span> {{dataItem.country}}</div>
15+
<div><span class='categoryStyle'>City:</span> {{dataItem.city}}</div>
16+
<div><span class='categoryStyle'>Street:</span> {{dataItem.street}}</div>
17+
</div>
18+
<div>
19+
<div> <span class='categoryStyle'>Work Phone:</span> {{dataItem.work_phone}}</div>
20+
<div> <span class='categoryStyle'>Mobile Phone:</span> {{dataItem.mobile_phone}}</div>
21+
</div>
22+
</div>
23+
</div>
24+
</igx-tabs-group>
25+
<igx-tabs-group label="Deals">
26+
<div class='tabContent'>
27+
<igx-pie-chart [dataSource]="getPieData(dataItem)"
28+
width="50%"
29+
height="200px"
30+
[outlines]="['transparent']"
31+
leaderLineVisibility='collapsed'
32+
labelMemberPath="Label" [formatLabel]='formatPieLabel'
33+
valueMemberPath="Value" [brushes]='["rgb(171, 223, 29)", "rgb(228, 19, 16)", "rgb(0, 111, 138)"]'
34+
[labelsPosition]="'outsideEnd'">
35+
</igx-pie-chart>
36+
<igx-grid style='margin:10px;' displayDensity="compact" (onColumnInit)='columnInit($event)' [autoGenerate]='true' [columnWidth]='"70px"' width='260px' [data]='dataItem.gridData ? dataItem.gridData: gridData(dataItem)'>
37+
</igx-grid>
38+
</div>
39+
</igx-tabs-group>
40+
<igx-tabs-group label="Sales">
41+
<div class='tabContent' style='flex-direction: column;'>
42+
<igx-legend #legend orientation="horizontal"></igx-legend>
43+
<igx-category-chart height="300px" [legend]="legend"
44+
[dataSource]="dataItem.chartData ? dataItem.chartData : getChartData(dataItem)"
45+
chartType="Line"
46+
chartTitle="Sales"
47+
subtitle="(Estimated, Actual)"
48+
xAxisInterval="1"
49+
[brushes]='["rgb(0, 111, 138)", "rgb(171, 223, 29)"]'
50+
[xAxisFormatLabel]="formatDateLabel"
51+
[includedProperties]="include"
52+
[crosshairsDisplayMode]="'Horizontal'"
53+
[crosshairsAnnotationEnabled]="true"
54+
isHorizontalZoomEnabled="false"
55+
isVerticalZoomEnabled="false">
56+
</igx-category-chart>
57+
</div>
58+
</igx-tabs-group>
59+
</igx-tabs>
60+
</div>
61+
</ng-template>
62+
</igx-grid>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
.categoryStyle{
2+
font-weight: 600;
3+
}
4+
.tabContent {
5+
display:flex;
6+
justify-content: space-between;
7+
margin: 10px;
8+
}
9+
10+
.tabInnerContent {
11+
display:flex;
12+
justify-content: space-around;
13+
width: 100%;
14+
}
15+
.tabInnerContent > div {
16+
margin: 10px;
17+
}

0 commit comments

Comments
 (0)