Skip to content

Commit e65507d

Browse files
PlamenaMitevaLipata
authored andcommitted
fix(grid): add contentChild decorator to dragIndicatorIconTemplate in HGrid #4769 (#6309)
1 parent a6ff963 commit e65507d

File tree

5 files changed

+21
-64
lines changed

5 files changed

+21
-64
lines changed

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ export enum GridKeydownTargetType {
244244
export abstract class IgxGridBaseComponent extends DisplayDensityBase implements
245245
OnInit, OnChanges, OnDestroy, AfterContentInit, AfterViewInit {
246246
private _scrollWidth: number;
247+
private _customDragIndicatorIconTemplate: TemplateRef<any>;
247248
protected _init = true;
248249

249250
public get scrollWidth() {
@@ -1558,6 +1559,23 @@ export abstract class IgxGridBaseComponent extends DisplayDensityBase implements
15581559
@ContentChildren(IgxColumnComponent, { read: IgxColumnComponent, descendants: true })
15591560
public columnList: QueryList<IgxColumnComponent>;
15601561

1562+
/**
1563+
* @hidden
1564+
* @internal
1565+
*/
1566+
@ContentChildren(IgxDragIndicatorIconDirective, { read: TemplateRef, descendants: false })
1567+
public dragIndicatorIconTemplates: QueryList<TemplateRef<any>>;
1568+
/**
1569+
* The custom template, if any, that should be used when rendering the row drag indicator icon
1570+
*/
1571+
public get dragIndicatorIconTemplate(): TemplateRef<any> {
1572+
return this._customDragIndicatorIconTemplate || this.dragIndicatorIconTemplates.first;
1573+
}
1574+
1575+
public set dragIndicatorIconTemplate(val: TemplateRef<any>) {
1576+
this._customDragIndicatorIconTemplate = val;
1577+
}
1578+
15611579
/**
15621580
*@hidden
15631581
*/

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

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import { IgxGridSummaryService } from '../summaries/grid-summary.service';
2929
import { IgxGridSelectionService, IgxGridCRUDService } from '../../core/grid-selection';
3030
import { IgxOverlayService } from '../../services/index';
3131
import { IgxForOfSyncService, IgxForOfScrollSyncService } from '../../directives/for-of/for_of.sync.service';
32-
import { IgxDragIndicatorIconDirective } from '../row-drag.directive';
3332
import { IgxGridMRLNavigationService } from '../grid-mrl-navigation.service';
3433

3534
let NEXT_ID = 0;
@@ -471,27 +470,6 @@ export class IgxGridComponent extends IgxGridBaseComponent implements IGridDataB
471470
@ContentChild(IgxGroupByRowTemplateDirective, { read: IgxGroupByRowTemplateDirective, static: false })
472471
protected groupTemplate: IgxGroupByRowTemplateDirective;
473472

474-
/**
475-
* The custom template, if any, that should be used when rendering the row drag indicator icon
476-
*
477-
* ```typescript
478-
* // Set in typescript
479-
* const myCustomTemplate: TemplateRef<any> = myComponent.customTemplate;
480-
* myComponent.dragIndicatorIconTemplate = myCustomTemplate;
481-
* ```
482-
* ```html
483-
* <!-- Set in markup -->
484-
* <igx-grid #grid>
485-
* ...
486-
* <ng-template igxDragIndicatorIcon>
487-
* <igx-icon fontSet="material">info</igx-icon>
488-
* </ng-template>
489-
* </igx-grid>
490-
* ```
491-
*/
492-
@ContentChild(IgxDragIndicatorIconDirective, { read: TemplateRef, static: false })
493-
public dragIndicatorIconTemplate: TemplateRef<any> = null;
494-
495473
@ViewChildren(IgxGridGroupByRowComponent, { read: IgxGridGroupByRowComponent })
496474
private _groupsRowList: QueryList<IgxGridGroupByRowComponent>;
497475

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

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -129,26 +129,6 @@ export abstract class IgxHierarchicalGridBaseComponent extends IgxGridBaseCompon
129129
this.hgridAPI = <IgxHierarchicalGridAPIService>gridAPI;
130130
}
131131

132-
/**
133-
* The custom template, if any, that should be used when rendering the row drag indicator icon
134-
*
135-
* ```typescript
136-
* // Set in typescript
137-
* const myCustomTemplate: TemplateRef<any> = myComponent.customTemplate;
138-
* myComponent.dragIndicatorIconTemplate = myCustomTemplate;
139-
* ```
140-
* ```html
141-
* <!-- Set in markup -->
142-
* <igx-grid #grid>
143-
* ...
144-
* <ng-template igxDragIndicatorIcon>
145-
* <igx-icon fontSet="material">info</igx-icon>
146-
* </ng-template>
147-
* </igx-grid>
148-
* ```
149-
*/
150-
public dragIndicatorIconTemplate: TemplateRef<any> = null;
151-
152132
/**
153133
* @hidden
154134
*/

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,9 @@ export class IgxHierarchicalGridComponent extends IgxHierarchicalGridBaseCompone
384384
this.toolbarCustomContentTemplates = this.parentIsland ?
385385
this.parentIsland.toolbarCustomContentTemplates :
386386
this.toolbarCustomContentTemplates;
387+
this.dragIndicatorIconTemplate = this.parentIsland ?
388+
this.parentIsland.dragIndicatorIconTemplate :
389+
this.dragIndicatorIconTemplate;
387390
}
388391

389392
private updateSizes() {

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

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ import { IgxColumnComponent } from '../column.component';
4242
import { first, takeUntil } from 'rxjs/operators';
4343
import { IgxRowLoadingIndicatorTemplateDirective } from './tree-grid.directives';
4444
import { IgxForOfSyncService, IgxForOfScrollSyncService } from '../../directives/for-of/for_of.sync.service';
45-
import { IgxDragIndicatorIconDirective } from '../row-drag.directive';
4645

4746
let NEXT_ID = 0;
4847

@@ -304,27 +303,6 @@ export class IgxTreeGridComponent extends IgxGridBaseComponent implements IGridD
304303
@ContentChild(IgxRowLoadingIndicatorTemplateDirective, { read: IgxRowLoadingIndicatorTemplateDirective, static: false })
305304
protected rowLoadingTemplate: IgxRowLoadingIndicatorTemplateDirective;
306305

307-
/**
308-
* The custom template, if any, that should be used when rendering the row drag indicator icon
309-
*
310-
* ```typescript
311-
* // Set in typescript
312-
* const myCustomTemplate: TemplateRef<any> = myComponent.customTemplate;
313-
* myComponent.dragIndicatorIconTemplate = myCustomTemplate;
314-
* ```
315-
* ```html
316-
* <!-- Set in markup -->
317-
* <igx-grid #grid>
318-
* ...
319-
* <ng-template igxDragIndicatorIcon>
320-
* <igx-icon fontSet="material">info</igx-icon>
321-
* </ng-template>
322-
* </igx-grid>
323-
* ```
324-
*/
325-
@ContentChild(IgxDragIndicatorIconDirective, { read: TemplateRef, static: false })
326-
public dragIndicatorIconTemplate: TemplateRef<any> = null;
327-
328306
/**
329307
* An @Input property that provides a template for the row loading indicator when load on demand is enabled.
330308
* ```html

0 commit comments

Comments
 (0)