Skip to content

Commit cf0dd2a

Browse files
committed
refactor(grids): use internal grid type instead of element tagName
1 parent ff352df commit cf0dd2a

File tree

5 files changed

+14
-25
lines changed

5 files changed

+14
-25
lines changed

projects/igniteui-angular/src/lib/grids/cell.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,7 +1019,7 @@ export class IgxGridCellComponent implements OnInit, OnChanges, OnDestroy, CellT
10191019
* @internal
10201020
*/
10211021
public pointerenter = (event: PointerEvent) => {
1022-
const isHierarchicalGrid = this.grid.nativeElement.tagName.toLowerCase() === 'igx-hierarchical-grid';
1022+
const isHierarchicalGrid = this.grid.type === 'hierarchical';
10231023
if (isHierarchicalGrid && (!this.grid.navigation?.activeNode?.gridID || this.grid.navigation.activeNode.gridID !== this.gridID)) {
10241024
return;
10251025
}
@@ -1049,7 +1049,7 @@ export class IgxGridCellComponent implements OnInit, OnChanges, OnDestroy, CellT
10491049
* @internal
10501050
*/
10511051
public pointerup = (event: PointerEvent) => {
1052-
const isHierarchicalGrid = this.grid.nativeElement.tagName.toLowerCase() === 'igx-hierarchical-grid';
1052+
const isHierarchicalGrid = this.grid.type === 'hierarchical';
10531053
if (!this.platformUtil.isLeftClick(event) || (isHierarchicalGrid && (!this.grid.navigation?.activeNode?.gridID ||
10541054
this.grid.navigation.activeNode.gridID !== this.gridID))) {
10551055
return;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7220,7 +7220,7 @@ export abstract class IgxGridBaseDirective implements GridType,
72207220
const keysAndData = [];
72217221
const activeEl = this.selectionService.activeElement;
72227222

7223-
if (this.nativeElement.tagName.toLowerCase() === 'igx-hierarchical-grid') {
7223+
if (this.type === 'hierarchical') {
72247224
const expansionRowIndexes = [];
72257225
for (const [key, value] of this.expansionStates.entries()) {
72267226
if (value) {
@@ -7257,7 +7257,7 @@ export abstract class IgxGridBaseDirective implements GridType,
72577257
const totalItems = (this as any).totalItemCount ?? 0;
72587258
const isRemote = totalItems && totalItems > this.dataView.length;
72597259
let selectionMap;
7260-
if (this.nativeElement.tagName.toLowerCase() === 'igx-hierarchical-grid' && selectionCollection.size > 0) {
7260+
if (this.type === 'hierarchical' && selectionCollection.size > 0) {
72617261
selectionMap = isRemote ? Array.from(selectionCollection) :
72627262
Array.from(selectionCollection).filter((tuple) => tuple[0] < source.length);
72637263
} else {

projects/igniteui-angular/src/lib/grids/row-drag.directive.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ export class IgxRowDragDirective extends IgxDragDirective implements OnDestroy {
161161
};
162162

163163
private get isHierarchicalGrid() {
164-
return this.row.grid.nativeElement.tagName.toLowerCase() === 'igx-hierarchical-grid';
164+
return this.row.grid.type === 'hierarchical';
165165
}
166166
}
167167

projects/igniteui-angular/src/lib/grids/summaries/grid-summary.service.ts

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,15 @@ export class IgxGridSummaryService {
5757
if (this.summaryCacheMap.size === 1 && this.summaryCacheMap.has(this.rootSummaryID)) {
5858
return;
5959
}
60-
if (this.isTreeGrid) {
60+
if (this.grid.type === 'tree') {
6161
if (this.grid.transactions.enabled && this.deleteOperation) {
6262
this.deleteOperation = false;
6363
// TODO: this.removeChildRowSummaries(rowID, columnName);
6464
this.summaryCacheMap.clear();
6565
return;
6666
}
6767
this.removeAllTreeGridSummaries(rowID, columnName);
68-
} else if (this.isHierarchicalGrid) {
68+
} else if (this.grid.type === 'hierarchical') {
6969
if (this.grid.transactions.enabled && this.deleteOperation) {
7070
this.deleteOperation = false;
7171
this.summaryCacheMap.clear();
@@ -244,13 +244,4 @@ export class IgxGridSummaryService {
244244
});
245245
}
246246
}
247-
248-
private get isTreeGrid() {
249-
return this.grid.nativeElement.tagName.toLowerCase() === 'igx-tree-grid';
250-
}
251-
252-
private get isHierarchicalGrid() {
253-
return this.grid.nativeElement.tagName.toLowerCase() === 'igx-hierarchical-grid';
254-
}
255-
256247
}

projects/igniteui-angular/src/lib/services/exporter-common/base-export-service.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -244,17 +244,16 @@ export abstract class IgxBaseExporter {
244244
}
245245

246246
const columnList = this.getColumns(columns);
247-
const tagName = grid.nativeElement.tagName.toLowerCase();
248247

249-
if (tagName === 'igx-hierarchical-grid') {
248+
if (grid.type === 'hierarchical') {
250249
this._ownersMap.set(grid, columnList);
251250

252251
const childLayoutList = grid.childLayoutList;
253252

254253
for (const island of childLayoutList) {
255254
this.mapHierarchicalGridColumns(island, grid.data[0]);
256255
}
257-
} else if (tagName === 'igx-pivot-grid') {
256+
} else if (grid.type === 'pivot') {
258257
this.pivotGridColumns = [];
259258
this.isPivotGridExport = true;
260259
this.pivotGridKeyValueMap = new Map<string, string>();
@@ -540,24 +539,23 @@ export abstract class IgxBaseExporter {
540539

541540
private prepareData(grid: GridType) {
542541
this.flatRecords = [];
543-
const tagName = grid.nativeElement.tagName.toLowerCase();
544542
const hasFiltering = (grid.filteringExpressionsTree && grid.filteringExpressionsTree.filteringOperands.length > 0) ||
545543
(grid.advancedFilteringExpressionsTree && grid.advancedFilteringExpressionsTree.filteringOperands.length > 0);
546544
const expressions = grid.groupingExpressions ? grid.groupingExpressions.concat(grid.sortingExpressions || []) : grid.sortingExpressions;
547545
const hasSorting = expressions && expressions.length > 0;
548546
let setSummaryOwner = false;
549547

550-
switch (tagName) {
551-
case 'igx-pivot-grid': {
548+
switch (grid.type) {
549+
case 'pivot': {
552550
this.preparePivotGridData(grid);
553551
break;
554552
}
555-
case 'igx-hierarchical-grid': {
553+
case 'hierarchical': {
556554
this.prepareHierarchicalGridData(grid, hasFiltering, hasSorting);
557555
setSummaryOwner = true;
558556
break;
559557
}
560-
case 'igx-tree-grid': {
558+
case 'tree': {
561559
this.prepareTreeGridData(grid, hasFiltering, hasSorting);
562560
break;
563561
}
@@ -1300,7 +1298,7 @@ export abstract class IgxBaseExporter {
13001298
}
13011299

13021300
private addPivotGridColumns(grid: any) {
1303-
if (grid.nativeElement.tagName.toLowerCase() !== 'igx-pivot-grid') {
1301+
if (grid.type !== 'pivot') {
13041302
return;
13051303
}
13061304

0 commit comments

Comments
 (0)