Skip to content

Commit 965ae93

Browse files
committed
chore(row-drag): Adding a getDragGhostCustomTemplate method #6081
1 parent 7bce412 commit 965ae93

File tree

7 files changed

+39
-22
lines changed

7 files changed

+39
-22
lines changed

CHANGELOG.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ All notable changes for each version of this project will be documented in this
55
### New Features
66
- `IgxRowDragGhost` directive is added. It allows providing a custom template for the drag ghost when dragging a row.
77
```html
8-
<igx-grid #grid1 [data]="remote | async" [primaryKey]="'ProductID'"
8+
<igx-grid #grid1 [data]="remote | async" primaryKey="ProductID"
99
[rowDraggable]="true">
10-
<igx-column [field]="'ProductName'"></igx-column>
11-
<igx-column [field]="'ProductID'"></igx-column>
12-
<igx-column [field]="'UnitsInStock'"></igx-column>
10+
<igx-column field="ProductName"></igx-column>
11+
<igx-column field="ProductID"></igx-column>
12+
<igx-column field="UnitsInStock"></igx-column>
1313
<ng-template let-data igxRowDragGhost>
1414
<div>
1515
Moving {{data.ProductName}}!

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

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1942,20 +1942,8 @@ export abstract class IgxGridBaseComponent extends DisplayDensityBase implements
19421942
* @hidden
19431943
* @internal
19441944
*/
1945-
public get dragGhostCustomTemplate(): TemplateRef<IgxRowDragGhostDirective> {
1946-
if (this.dragGhostCustomTemplates && this.dragGhostCustomTemplates.first) {
1947-
return this.dragGhostCustomTemplates.first.templateRef;
1948-
}
1949-
1950-
return null;
1951-
}
1952-
1953-
/**
1954-
* @hidden
1955-
* @internal
1956-
*/
1957-
@ContentChildren(IgxRowDragGhostDirective, { read: IgxRowDragGhostDirective, descendants: false })
1958-
public dragGhostCustomTemplates: QueryList<IgxRowDragGhostDirective>;
1945+
@ContentChildren(IgxRowDragGhostDirective, { read: TemplateRef, descendants: false })
1946+
public dragGhostCustomTemplates: QueryList<TemplateRef<any>>;
19591947

19601948
/**
19611949
* @hidden
@@ -3203,6 +3191,18 @@ export abstract class IgxGridBaseComponent extends DisplayDensityBase implements
32033191
}
32043192
}
32053193

3194+
/**
3195+
* @hidden
3196+
* @internal
3197+
*/
3198+
public getDragGhostCustomTemplate() {
3199+
if (this.dragGhostCustomTemplates && this.dragGhostCustomTemplates.first) {
3200+
return this.dragGhostCustomTemplates.first;
3201+
}
3202+
3203+
return null;
3204+
}
3205+
32063206
/**
32073207
* @hidden
32083208
*/

projects/igniteui-angular/src/lib/grids/grid/grid-row.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<div class="igx-grid__row-indentation igx-grid__row-indentation--level-{{grid.groupingExpressions.length}}"></div>
33
</ng-container>
44
<ng-container *ngIf="rowDraggable">
5-
<div [class]="resolveDragIndicatorClasses" [igxRowDrag]="this" (click)="$event.stopPropagation()" [ghostTemplate]="this.grid.dragGhostCustomTemplate">
5+
<div [class]="resolveDragIndicatorClasses" [igxRowDrag]="this" (click)="$event.stopPropagation()" [ghostTemplate]="this.grid.getDragGhostCustomTemplate()">
66
<ng-container *ngTemplateOutlet="this.grid.dragIndicatorIconTemplate ? this.grid.dragIndicatorIconTemplate : this.grid.dragIndicatorIconBase"></ng-container>
77
</div>
88
</ng-container>

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,17 @@ export class IgxHierarchicalGridComponent extends IgxHierarchicalGridBaseCompone
662662
}
663663
}
664664

665+
/**
666+
* @hidden
667+
* @internal
668+
*/
669+
public getDragGhostCustomTemplate(): TemplateRef<any> {
670+
if (this.parentIsland) {
671+
return this.parentIsland.getDragGhostCustomTemplate();
672+
}
673+
return super.getDragGhostCustomTemplate();
674+
}
675+
665676
/**
666677
* @hidden
667678
*/

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
</ng-template>
1616

1717
<ng-container *ngIf="rowDraggable">
18-
<div [class]="resolveDragIndicatorClasses" [igxRowDrag]="this" (click)="$event.stopPropagation()" [ghostTemplate]="this.grid.dragGhostCustomTemplate">
18+
<div [class]="resolveDragIndicatorClasses" [igxRowDrag]="this" (click)="$event.stopPropagation()" [ghostTemplate]="this.grid.getDragGhostCustomTemplate()">
1919
<ng-container *ngTemplateOutlet="this.grid.dragIndicatorIconTemplate ? this.grid.dragIndicatorIconTemplate : this.grid.dragIndicatorIconBase"></ng-container>
2020
</div>
2121
</ng-container>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<ng-container *ngIf="rowDraggable">
2-
<div [class]="resolveDragIndicatorClasses" [igxRowDrag]="this" (click)="$event.stopPropagation()" [ghostTemplate]="this.grid.dragGhostCustomTemplate">
2+
<div [class]="resolveDragIndicatorClasses" [igxRowDrag]="this" (click)="$event.stopPropagation()" [ghostTemplate]="this.grid.getDragGhostCustomTemplate()">
33
<ng-container *ngTemplateOutlet="this.grid.dragIndicatorIconTemplate ? this.grid.dragIndicatorIconTemplate : this.grid.dragIndicatorIconBase"></ng-container>
44
</div>
55
</ng-container>

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ <h4 class="sample-title">Sample One</h4>
2929
<igx-column field="ChildLevels" [resizable]="true" [groupable]='true'></igx-column>
3030
<igx-column field="ProductName" [resizable]="true" [groupable]='true'></igx-column>
3131
</igx-column-group>
32+
<ng-template let-data igxRowDragGhost>
33+
<div class="dragGhost">
34+
<igx-icon fontSet="material"></igx-icon>
35+
Moving child {{data.ProductName}}!
36+
</div>
37+
</ng-template>
3238
<igx-row-island [key]="'childData'" [autoGenerate]="false" [rowSelectable]='isRowSelectable' [allowFiltering]='true' >
3339
<igx-column field="ID" [hasSummary]='true'></igx-column>
3440
<igx-column-group header="Information3">
@@ -56,7 +62,7 @@ <h4 class="sample-title">Sample One</h4>
5662
<ng-template let-data igxRowDragGhost>
5763
<div class="dragGhost">
5864
<igx-icon fontSet="material"></igx-icon>
59-
Moving {{data.ProductName}}!
65+
Moving parent {{data.ProductName}}!
6066
</div>
6167
</ng-template>
6268
</igx-hierarchical-grid>

0 commit comments

Comments
 (0)