@@ -43,6 +43,7 @@ describe('IgxGrid - Row Drag Tests #grid', () => {
43
43
TestBed . configureTestingModule ( {
44
44
declarations : [
45
45
IgxGridRowDraggableComponent ,
46
+ IgxGridRowCustomGhostDraggableComponent ,
46
47
IgxGridFeaturesRowDragComponent ,
47
48
IgxHierarchicalGridTestComponent ,
48
49
IgxTreeGridTestComponent
@@ -383,6 +384,28 @@ describe('IgxGrid - Row Drag Tests #grid', () => {
383
384
const ghostElements = document . getElementsByClassName ( CSS_CLASS_GHOST_ROW ) ;
384
385
expect ( ghostElements . length ) . toEqual ( 0 ) ;
385
386
} ) ) ;
387
+
388
+ it ( 'should correctly create custom ghost element' , ( async ( ) => {
389
+ fixture = TestBed . createComponent ( IgxGridRowCustomGhostDraggableComponent ) ;
390
+ grid = fixture . componentInstance . instance ;
391
+ fixture . detectChanges ( ) ;
392
+ dragIndicatorElements = fixture . debugElement . queryAll ( By . css ( '.' + CSS_CLASS_DRAG_INDICATOR ) ) ;
393
+ dragRows = fixture . debugElement . queryAll ( By . directive ( IgxRowDragDirective ) ) ;
394
+ const dragIndicatorElement = dragIndicatorElements [ 2 ] . nativeElement ;
395
+ const startPoint : Point = UIInteractions . getPointFromElement ( dragIndicatorElement ) ;
396
+ const movePoint : Point = UIInteractions . getPointFromElement ( rows [ 4 ] . nativeElement ) ;
397
+ const dropPoint : Point = UIInteractions . getPointFromElement ( dropAreaElement ) ;
398
+ let ghostElements : HTMLCollection ;
399
+
400
+ await pointerDown ( dragIndicatorElement , startPoint , fixture ) ;
401
+ await pointerMove ( dragIndicatorElement , movePoint , fixture ) ;
402
+ await pointerMove ( dragIndicatorElement , dropPoint , fixture ) ;
403
+ ghostElements = document . getElementsByClassName ( CSS_CLASS_GHOST_ROW ) ;
404
+ expect ( ghostElements . length ) . toEqual ( 1 ) ;
405
+
406
+ const ghostText = document . getElementsByClassName ( CSS_CLASS_GHOST_ROW ) [ 0 ] . textContent ;
407
+ expect ( ghostText ) . toEqual ( ' Moving a row! ' ) ;
408
+ } ) ) ;
386
409
} ) ;
387
410
describe ( 'Grid Features Integration Tests' , ( ) => {
388
411
let dragGrid : IgxGridComponent ;
@@ -634,8 +657,8 @@ describe('IgxGrid - Row Drag Tests #grid', () => {
634
657
expect ( row . grid . rowDragging ) . toBeTruthy ( ) ;
635
658
636
659
const ghostElements = document . getElementsByClassName ( CSS_CLASS_GHOST_ROW ) ;
637
- const ghostElement = ghostElements [ 0 ] ;
638
- expect ( ghostElements . length ) . toEqual ( 1 ) ;
660
+ const ghostElement = ghostElements [ 1 ] ;
661
+ expect ( ghostElements . length ) . toEqual ( 2 ) ;
639
662
expect ( ghostElement . classList . contains ( CSS_CLASS_SELECTED_ROW ) ) . toBeFalsy ( ) ;
640
663
641
664
await pointerMove ( dragIndicatorElement , dropPoint , fixture ) ;
@@ -959,6 +982,65 @@ export class IgxGridRowDraggableComponent extends DataParent {
959
982
}
960
983
}
961
984
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
+
962
1044
@Component ( {
963
1045
template : `
964
1046
<igx-grid #dragGrid
0 commit comments