Skip to content

Commit c40b0a0

Browse files
authored
Merge pull request #12460 from IgniteUI/dpetev/demos-type-checks
Fix demos type checks and warnings, some cleanup
2 parents fdc196d + 9b739dd commit c40b0a0

20 files changed

+63
-65
lines changed

src/app/grid-cellEditing/grid-cellEditing.component.html

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,6 @@ <h3>Grid with primary key ProductID</h3>
2525
<igx-column field="ReorderLevel" width="200px" [sortable]="true" [filterable]="true" [editable]="true" [dataType]="'number'" [hasSummary]="false">
2626
</igx-column>
2727
<igx-column field="ProductName" width="200px" [groupable]="kk" [header]="pname" [sortable]="true" [dataType]="'string'" [editable]="true" [resizable]="true">
28-
<ng-template igxCellValidationError let-cell='cell'>
29-
<div *ngIf="cell.formGroup?.get(cell.column?.field).errors?.['forbiddenName']">
30-
This name is forbidden.
31-
</div>
32-
</ng-template>
3328
</igx-column>
3429
<igx-column required field="UnitsInStock" header="UnitsInStock" width="200px" [dataType]="'number'" [editable]="true" [sortable]="true" [hasSummary]="false">
3530
</igx-column>
@@ -74,4 +69,4 @@ <h3>Grid without PK</h3>
7469
<igx-paginator [perPage]="10"></igx-paginator>
7570
</igx-grid>
7671
<button (click)="moveColumns()">Move OrderDate and ProductName</button>
77-
<button (click)="updateSelectedCell()">Update Selected Cell</button>
72+
<button (click)="updateSelectedCell()">Update Selected Cell</button>

src/app/grid-cellEditing/grid-cellEditing.component.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,6 @@ export class GridCellEditingComponent {
167167
const secColumn = this.gridWithoutPK.getColumnByName('OrderDate');
168168
this.gridWithoutPK.moveColumn(column, secColumn);
169169
}
170-
public checkValid(cell) {
171-
debugger;
172-
return cell.formGroup?.get(cell.column?.field).errors?.['appForbiddenName'];
173-
}
174170
public updateSelectedCell() {
175171
let newValue;
176172
const selectedCell = this.gridWithoutPK.selectedCells[0];

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

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
import { Component, ViewChild } from '@angular/core';
22
import {
3-
IgxColumnComponent,
3+
ColumnType,
44
IgxNumberSummaryOperand,
55
IgxSummaryResult,
6-
IgxExcelExporterService,
76
IGridToolbarExportEventArgs,
87
IgxExporterOptionsBase,
9-
IgxExcelExporterOptions,
108
IColumnExportingEventArgs,
119
IRowExportingEventArgs,
1210
IgxGridComponent,
@@ -91,31 +89,29 @@ export class GridExportComponent {
9189
this.productId = GRID_DATA.length;
9290
}
9391

94-
public toggleSummary(column: IgxColumnComponent) {
92+
public toggleSummary(column: ColumnType) {
9593
column.hasSummary = !column.hasSummary;
96-
this.grid.summaryService.clearSummaryCache();
97-
this.tGrid.summaryService.clearSummaryCache();
9894
}
9995

10096
public configureExport(args: IGridToolbarExportEventArgs) {
10197
console.log(args);
102-
//const options: IgxExporterOptionsBase = args.options;
98+
// const options: IgxExporterOptionsBase = args.options;
99+
100+
// // Change exporter options
103101

104-
// Change exporter options
105-
//
106102
// options.fileName = `Report_${new Date().toDateString()}`;
107103
// options.exportSummaries = false;
108104

109-
// Cancel column exporting
110-
//
105+
// // Cancel column exporting
106+
111107
// args.exporter.columnExporting.subscribe((colExportingArgs: IColumnExportingEventArgs) => {
112108
// if (colExportingArgs.columnIndex === 1) {
113109
// colExportingArgs.cancel = true;
114110
// }
115111
// });
116112

117-
// Cancel row exporting
118-
//
113+
// // Cancel row exporting
114+
119115
// args.exporter.rowExporting.subscribe((rowExportingArgs: IRowExportingEventArgs) => {
120116
// if (rowExportingArgs.rowIndex === 1) {
121117
// rowExportingArgs.cancel = true;

src/app/grid-filter-template/grid-filter-template.sample.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
IgxNumberFilteringOperand,
66
IgxDateFilteringOperand,
77
IgxStringFilteringOperand,
8-
IgxColumnComponent,
8+
ColumnType,
99
GridSelectionMode
1010
} from 'igniteui-angular';
1111

@@ -511,7 +511,7 @@ export class GridFilterTemplateSampleComponent implements OnInit {
511511
this.selectionMode = GridSelectionMode.multiple;
512512
}
513513

514-
public onInput(input: any, column: IgxColumnComponent) {
514+
public onInput(input: any, column: ColumnType) {
515515
let operand = null;
516516
let value = input.value;
517517

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<div class="dark-grid">
2-
<igx-grid batchEditing ='true' #grid1 [data]="remoteData | async" [height]="'500px'" [width]="'100%'" [primaryKey]="'ProductID'" [autoGenerate]='true' (dataPreLoad)="handlePreLoad()" [clipboardOptions]="clipboardOptions"
3-
(sortingDone)="processData(true)" (columnInit)='onColumnInit($event)' rowSelection="multiple">
2+
<igx-grid [batchEditing]="true" #grid1 [data]="remoteData | async" height="500px" width="100%" primaryKey="ProductID" [autoGenerate]="true" (dataPreLoad)="handlePreLoad()" [clipboardOptions]="clipboardOptions"
3+
(sortingDone)="processData(true)" (columnInit)="onColumnInit($event)" rowSelection="multiple">
44
</igx-grid>
55
</div>

src/app/grid-summaries/grid-summaries.sample.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<div class="density-chooser">
22
<igx-buttongroup [values]="displayDensities" (selected)="selectDensity($event)"></igx-buttongroup>
33
</div>
4-
<igx-grid #grid1 [pinning]="pinningConfig" [data]="data" [autoGenerate]="false" [displayDensity]="'compact'" [width]="w" [height]="h"
4+
<igx-grid #grid1 [pinning]="pinningConfig" [data]="data" [autoGenerate]="false" [width]="w" [height]="h"
55
[allowFiltering]="true" [filterMode]="'excelStyleFilter'" [summaryCalculationMode]="'rootAndChildLevels'" [showSummaryOnCollapse]="true"
66
[summaryRowHeight]="rh" [rowSelection]="rowSelection ? 'multiple' : 'none'" [displayDensity]="density">
77
<igx-grid-toolbar *ngIf="showToolbar" [displayDensity]="grid1.displayDensity">

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import {
44
IgxNumberSummaryOperand,
55
IgxSummaryResult,
66
ColumnPinningPosition,
7-
IPinningConfig
7+
IPinningConfig,
8+
DisplayDensity
89
} from 'igniteui-angular';
910

1011
class MySummary extends IgxNumberSummaryOperand {
@@ -52,7 +53,7 @@ export class GridSummaryComponent implements OnInit {
5253
public columnPinning = false;
5354
public pinningConfig: IPinningConfig = { columns: ColumnPinningPosition.End };
5455
public rowSelection = false;
55-
public density = 'compact';
56+
public density: DisplayDensity = 'compact';
5657
public displayDensities;
5758

5859
public data = [{

src/app/grid-validation/grid-validation.sample.component.html

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ <h4>Grid without transactions</h4>
44
<igx-switch [(ngModel)]="rowEditNoTransactions">Row edit</igx-switch>
55
<igx-grid [rowStyles]="rowStyles" validationTrigger='change' (validationStatusChange)='validationChange($event)' (cellEdit)='cellEdit($event)' (formGroupCreated)='formCreateHandler($event)' #gridNoTransactions primaryKey="ProductID" [data]="data" [rowEditable]="rowEditNoTransactions"
66
[width]="'1200px'" [height]="'800px'">
7-
<igx-column [field]="" editable='false'>
7+
<igx-column [field]="" [editable]='false'>
88
<ng-template igxCell let-cell="cell">
99
{{cell.row.validation.status}}
1010
</ng-template>
@@ -13,7 +13,7 @@ <h4>Grid without transactions</h4>
1313
<igx-column field='ProductName' appForbiddenName='bob' required [editable]='true'>
1414
<ng-template igxCellEditor let-cell="cell" let-value let-fc='formControl'>
1515
<input [(ngModel)]="cell.editValue"/>
16-
</ng-template>
16+
</ng-template>
1717
<ng-template igxCellValidationError let-cell='cell' let-defaultErr='defaultErrorTemplate'>
1818
<ng-container *ngTemplateOutlet="defaultErr" >
1919
</ng-container>
@@ -65,15 +65,14 @@ <h4>Grid with transactions</h4>
6565
<h4>TreeGrid</h4>
6666
<igx-tree-grid #treegrid [data]="treeData" primaryKey="employeeID" [rowStyles]="rowStyles"
6767
foreignKey="PID" [width]="'900px'" [height]="'800px'" [rowEditable]="true" [moving]="true">
68-
<igx-column [field]="" editable='false'>
68+
<igx-column [field]="" [editable]='false'>
6969
<ng-template igxCell let-cell="cell">
7070
{{cell.row.validation.status}}
7171
</ng-template>
7272
</igx-column>
7373
<igx-column *ngFor="let c of treeColumns" [field]="c.field" [dataType]="c.dataType" [header]="c.label"
74-
[pinned]="c.pinned" [groupable]="false" [resizable]="c.resizable" [width]="c.width"
75-
[sortable]="true" [filterable]="true" [editable]="true" [hidden]="c.hidden" [minWidth]="c.minWidth"
76-
[maxWidth]="c.maxWidth" required>
74+
[groupable]="false" [resizable]="c.resizable" [width]="c.width.toString()"
75+
[sortable]="true" [filterable]="true" [editable]="true" required>
7776
</igx-column>
7877
<igx-action-strip #actionstrip>
7978
<igx-grid-editing-actions [addRow]="true" [addChild]="actionstrip.context?.treeRow.level < 1">
@@ -87,10 +86,10 @@ <h4>TreeGrid</h4>
8786
<h4>Hierarchical Grid</h4>
8887
<igx-hierarchical-grid #hgrid [data]="hGridData" primaryKey="EmployeeID"
8988
[width]="'900px'" [height]="'550px'" [rowEditable]="true" [moving]="true">
90-
<igx-column *ngFor="let c of hColumns" [field]="c.field" required editable='true'>
89+
<igx-column *ngFor="let c of hColumns" [field]="c.field" required [editable]='true'>
9190
</igx-column>
9291
<igx-row-island [key]="'Orders'" [autoGenerate]="false">
93-
<igx-column *ngFor="let c of hColumns2" [field]="c.field" required appForbiddenName='bob' editable='true'>
92+
<igx-column *ngFor="let c of hColumns2" [field]="c.field" required appForbiddenName='bob' [editable]='true'>
9493
<ng-template igxCellValidationError let-cell='cell' let-defaultErr='defaultErrorTemplate'>
9594
<ng-container *ngTemplateOutlet="defaultErr" >
9695
</ng-container>

src/app/grid-validation/grid-validation.sample.component.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Component, Directive, ViewChild, Input } from '@angular/core';
22
import { data } from '../shared/data';
33

4-
import { IgxGridComponent, IRecordValidationState, IgxGridValidationService, IGridValidationStatusEventArgs, RowType } from 'igniteui-angular';
4+
import { IgxGridComponent, IRecordValidationState, IgxGridValidationService, IGridValidationStatusEventArgs, RowType, GridColumnDataType, IGridFormGroupCreatedEventArgs } from 'igniteui-angular';
55
import { AbstractControl, FormGroup, NG_VALIDATORS, ValidationErrors, ValidatorFn, Validators } from '@angular/forms';
66
import { HIERARCHICAL_DATA } from '../shared/hierarchicalData';
77

@@ -40,7 +40,7 @@ export class GridValidationSampleComponent {
4040
public rowStyles = {
4141
background: (row: RowType) => {
4242
return row.validation.status === 'INVALID' ? '#FF000033' : '#00000000';
43-
}
43+
}
4444
};
4545
public columns = [
4646
{ field: 'ProductID' },
@@ -49,7 +49,14 @@ export class GridValidationSampleComponent {
4949
{ field: 'UnitsInStock' }
5050
];
5151

52-
public treeColumns = [
52+
public treeColumns: {
53+
field: string;
54+
label: string;
55+
width: number;
56+
resizable: boolean;
57+
dataType: GridColumnDataType;
58+
hasSummary: boolean;
59+
}[] = [
5360
{ field: 'employeeID', label: 'ID', width: 200, resizable: true, dataType: 'number', hasSummary: false },
5461
{ field: 'Salary', label: 'Salary', width: 200, resizable: true, dataType: 'number', hasSummary: true },
5562
{ field: 'firstName', label: 'First Name', width: 300, resizable: true, dataType: 'string', hasSummary: false },
@@ -154,7 +161,7 @@ public hColumns2 = [
154161
// }
155162
}
156163

157-
public formCreateHandler(formGr: FormGroup) {
164+
public formCreateHandler(formGr: IGridFormGroupCreatedEventArgs) {
158165
// can add validators here
159166
// const prodName = formGr.get('ProductName');
160167
// prodName.addValidators(forbiddenNameValidator(/bob/i));

src/app/grid/grid.sample.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,8 @@ <h4>{{ col.field }}</h4>
150150
<ng-template igxHeader let-column="column">
151151
<p style="color: crimson">{{column.field}}</p>
152152
</ng-template>
153-
<ng-template igxCell let-item="item" let-ri="rowIndex" let-column="column">
154-
<igx-checkbox [checked]="item" (change)="grid2.updateCell($event.checkbox.checked, ri, column?.field)"></igx-checkbox>
153+
<ng-template igxCell let-value let-cell="cell">
154+
<igx-checkbox [checked]="value" (change)="grid2.updateCell($event.checkbox.checked, cell.row.key, cell.column.field)"></igx-checkbox>
155155
</ng-template>
156156
</igx-column>
157157
<igx-paginator [perPage]="10"></igx-paginator>
@@ -193,8 +193,8 @@ <h4 class="sample-title">Grid with templated cell remote data</h4>
193193
<ng-template igxHeader let-column="column">
194194
<p style="color: crimson">{{column.field</p>
195195
</ng-template>
196-
<ng-template igxCell let-item="item" let-ri="rowIndex" let-column="column">
197-
<igx-checkbox [checked]="item" (change)="grid3.updateCell($event.checkbox.checked, ri, column?.field)"></igx-checkbox>
196+
<ng-template igxCell let-item let-cell="cell">
197+
<igx-checkbox [checked]="item" (change)="grid3.updateCell($event.checkbox.checked, cell.row.key, cell.column.field)"></igx-checkbox>
198198
</ng-template>
199199
</igx-column>
200200
<igx-paginator [perPage]="10"></igx-paginator>

0 commit comments

Comments
 (0)