@@ -44,6 +44,7 @@ describe('IgxGrid - Row Drag Tests #grid', () => {
4444 TestBed . configureTestingModule ( {
4545 declarations : [
4646 IgxGridRowDraggableComponent ,
47+ IgxGridRowCustomGhostDraggableComponent ,
4748 IgxGridFeaturesRowDragComponent ,
4849 IgxHierarchicalGridTestComponent ,
4950 IgxTreeGridTestComponent
@@ -189,6 +190,27 @@ describe('IgxGrid - Row Drag Tests #grid', () => {
189190 ghostElements = document . getElementsByClassName ( CSS_CLASS_GHOST_ROW ) ;
190191 expect ( ghostElements . length ) . toEqual ( 0 ) ;
191192 } ) ) ;
193+ it ( 'should correctly create custom ghost element' , ( async ( ) => {
194+ fixture = TestBed . createComponent ( IgxGridRowCustomGhostDraggableComponent ) ;
195+ grid = fixture . componentInstance . instance ;
196+ fixture . detectChanges ( ) ;
197+ dragIndicatorElements = fixture . debugElement . queryAll ( By . css ( '.' + CSS_CLASS_DRAG_INDICATOR ) ) ;
198+ dragRows = fixture . debugElement . queryAll ( By . directive ( IgxRowDragDirective ) ) ;
199+ const dragIndicatorElement = dragIndicatorElements [ 2 ] . nativeElement ;
200+ const startPoint : Point = UIInteractions . getPointFromElement ( dragIndicatorElement ) ;
201+ const movePoint : Point = UIInteractions . getPointFromElement ( rows [ 4 ] . nativeElement ) ;
202+ const dropPoint : Point = UIInteractions . getPointFromElement ( dropAreaElement ) ;
203+ let ghostElements : HTMLCollection ;
204+
205+ await pointerDown ( dragIndicatorElement , startPoint , fixture ) ;
206+ await pointerMove ( dragIndicatorElement , movePoint , fixture ) ;
207+ await pointerMove ( dragIndicatorElement , dropPoint , fixture ) ;
208+ ghostElements = document . getElementsByClassName ( CSS_CLASS_GHOST_ROW ) ;
209+ expect ( ghostElements . length ) . toEqual ( 1 ) ;
210+
211+ const ghostText = document . getElementsByClassName ( CSS_CLASS_GHOST_ROW ) [ 0 ] . textContent ;
212+ expect ( ghostText ) . toEqual ( ' Moving a row! ' ) ;
213+ } ) ) ;
192214 it ( 'should apply drag class to row upon row dragging' , ( async ( ) => {
193215 const dragIndicatorElement = dragIndicatorElements [ 2 ] . nativeElement ;
194216 const row = rows [ 1 ] ;
@@ -960,6 +982,65 @@ export class IgxGridRowDraggableComponent extends DataParent {
960982 }
961983}
962984
985+ @Component ( {
986+ template : `
987+ <igx-grid #grid
988+ [width]='width'
989+ [height]='height'
990+ primaryKey="ID"
991+ [data]="data"
992+ [autoGenerate]="true" (onColumnInit)="columnsCreated($event)" (onGroupingDone)="onGroupingDoneHandler($event)"
993+ [rowEditable]="true" [rowDraggable]="enableRowDraggable"
994+ >
995+ <ng-template let-data igxRowDragGhost>
996+ <div class="dragGhost">
997+ <igx-icon fontSet="material"></igx-icon>
998+ Moving a row!
999+ </div>
1000+ </ng-template>
1001+ </igx-grid>
1002+ <div #dropArea class="droppable-area" igxDrop (dropped)="onRowDrop($event)"
1003+ [ngStyle]="{width:'100px', height:'100px', backgroundColor:'red'}">
1004+ </div>
1005+ <div #nonDroppableArea class="non-droppable-area"
1006+ [ngStyle]="{width:'100px', height:'100px', backgroundColor:'yellow'}">
1007+ </div>
1008+ `
1009+ } )
1010+ export class IgxGridRowCustomGhostDraggableComponent extends DataParent {
1011+ public width = '800px' ;
1012+ public height = null ;
1013+
1014+ @ViewChild ( IgxGridComponent , { read : IgxGridComponent , static : true } )
1015+ public instance : IgxGridComponent ;
1016+
1017+ @ViewChild ( 'dropArea' , { read : IgxDropDirective , static : true } )
1018+ public dropArea : IgxDropDirective ;
1019+
1020+ public enableSorting = false ;
1021+ public enableFiltering = false ;
1022+ public enableResizing = false ;
1023+ public enableEditing = true ;
1024+ public enableGrouping = true ;
1025+ public enableRowEditing = true ;
1026+ public enableRowDraggable = true ;
1027+ public currentSortExpressions ;
1028+
1029+ public columnsCreated ( column : IgxColumnComponent ) {
1030+ column . sortable = this . enableSorting ;
1031+ column . filterable = this . enableFiltering ;
1032+ column . resizable = this . enableResizing ;
1033+ column . editable = this . enableEditing ;
1034+ column . groupable = this . enableGrouping ;
1035+ }
1036+ public onGroupingDoneHandler ( sortExpr ) {
1037+ this . currentSortExpressions = sortExpr ;
1038+ }
1039+ public onRowDrop ( args ) {
1040+ args . cancel = true ;
1041+ }
1042+ }
1043+
9631044@Component ( {
9641045 template : `
9651046 <igx-grid #dragGrid
0 commit comments