@@ -392,6 +392,7 @@ describe('IgxGrid - Row Drag Tests #grid', () => {
392
392
fixture . detectChanges ( ) ;
393
393
dragIndicatorElements = fixture . debugElement . queryAll ( By . css ( '.' + CSS_CLASS_DRAG_INDICATOR ) ) ;
394
394
dragRows = fixture . debugElement . queryAll ( By . directive ( IgxRowDragDirective ) ) ;
395
+ const rowDragDirective = dragRows [ 1 ] . injector . get ( IgxRowDragDirective ) as any ;
395
396
const dragIndicatorElement = dragIndicatorElements [ 2 ] . nativeElement ;
396
397
const startPoint : Point = UIInteractions . getPointFromElement ( dragIndicatorElement ) ;
397
398
const movePoint : Point = UIInteractions . getPointFromElement ( rows [ 4 ] . nativeElement ) ;
@@ -404,6 +405,10 @@ describe('IgxGrid - Row Drag Tests #grid', () => {
404
405
ghostElements = document . getElementsByClassName ( CSS_CLASS_GHOST_ROW ) ;
405
406
expect ( ghostElements . length ) . toEqual ( 1 ) ;
406
407
408
+ expect ( rowDragDirective . ghostContext . data . ProductName ) . toEqual ( 'NetAdvantage' ) ;
409
+ expect ( rowDragDirective . ghostContext . data . ID ) . toEqual ( 2 ) ;
410
+ expect ( rowDragDirective . ghostContext . grid ) . toEqual ( grid ) ;
411
+
407
412
const ghostText = document . getElementsByClassName ( CSS_CLASS_GHOST_ROW ) [ 0 ] . textContent ;
408
413
expect ( ghostText ) . toEqual ( ' Moving a row! ' ) ;
409
414
} ) ) ;
@@ -810,7 +815,7 @@ describe('IgxGrid - Row Drag Tests #grid', () => {
810
815
dragRows = fixture . debugElement . queryAll ( By . directive ( IgxRowDragDirective ) ) ;
811
816
} ) ) ;
812
817
813
- it ( 'should be able to drag row on every hiearchical level' , ( async ( ) => {
818
+ it ( 'should be able to drag row on every hierarchical level' , ( async ( ) => {
814
819
// first level row
815
820
let dragIndicatorElement : Element = dragIndicatorElements [ 1 ] . nativeElement ;
816
821
let rowToDrag = dragGrid . getRowByIndex ( 0 ) ;
@@ -864,6 +869,41 @@ describe('IgxGrid - Row Drag Tests #grid', () => {
864
869
await pointerUp ( dragIndicatorElement , dropPoint , fixture ) ;
865
870
verifyRowDragEndEvent ( nestedChildGrid , rowToDrag , rowDragDirective , false , 1 ) ;
866
871
} ) ) ;
872
+
873
+ it ( 'should correctly create custom ghost element' , ( async ( ) => {
874
+ // first level row
875
+ let dragIndicatorElement : Element = dragIndicatorElements [ 1 ] . nativeElement ;
876
+ let rowToDrag = dragGrid . getRowByIndex ( 0 ) ;
877
+ let rowDragDirective = dragRows [ 0 ] . injector . get ( IgxRowDragDirective ) as any ;
878
+
879
+ let startPoint : Point = UIInteractions . getPointFromElement ( dragIndicatorElement ) ;
880
+ const movePoint : Point = UIInteractions . getPointFromElement ( dragGrid . getRowByIndex ( 3 ) . nativeElement ) ;
881
+ const dropPoint : Point = UIInteractions . getPointFromElement ( dropAreaElement ) ;
882
+
883
+ await pointerDown ( dragIndicatorElement , startPoint , fixture ) ;
884
+ await pointerMove ( dragIndicatorElement , movePoint , fixture ) ;
885
+ await pointerMove ( dragIndicatorElement , dropPoint , fixture ) ;
886
+ await pointerUp ( dragIndicatorElement , dropPoint , fixture ) ;
887
+
888
+ expect ( rowDragDirective . ghostContext . data . ProductName ) . toEqual ( 'Product: A0' ) ;
889
+ expect ( rowDragDirective . ghostContext . grid ) . toEqual ( dragGrid ) ;
890
+
891
+ // second level row
892
+ dragIndicatorElement = dragIndicatorElements [ 8 ] . nativeElement ;
893
+ const childGrid = dragGrid . hgridAPI . getChildGrids ( false ) [ 0 ] ;
894
+ rowToDrag = childGrid . getRowByIndex ( 0 ) ;
895
+ rowDragDirective = dragRows [ 4 ] . injector . get ( IgxRowDragDirective ) ;
896
+ startPoint = UIInteractions . getPointFromElement ( dragIndicatorElement ) ;
897
+
898
+ await pointerDown ( dragIndicatorElement , startPoint , fixture ) ;
899
+ await pointerMove ( dragIndicatorElement , movePoint , fixture ) ;
900
+ await pointerMove ( dragIndicatorElement , dropPoint , fixture ) ;
901
+ await pointerUp ( dragIndicatorElement , dropPoint , fixture ) ;
902
+
903
+ expect ( rowDragDirective . ghostContext . data . ProductName ) . toEqual ( 'Product: A0' ) ;
904
+ expect ( rowDragDirective . ghostContext . data . ChildLevels ) . toEqual ( 2 ) ;
905
+ expect ( rowDragDirective . ghostContext . grid ) . toEqual ( childGrid ) ;
906
+ } ) ) ;
867
907
} ) ;
868
908
describe ( 'Tree Grid Tests' , ( ) => {
869
909
let dragGrid : IgxTreeGridComponent ;
@@ -880,7 +920,7 @@ describe('IgxGrid - Row Drag Tests #grid', () => {
880
920
dragRows = fixture . debugElement . queryAll ( By . directive ( IgxRowDragDirective ) ) ;
881
921
} ) ) ;
882
922
883
- it ( 'should be able to drag row on every hiearchical level' , ( async ( ) => {
923
+ it ( 'should be able to drag row on every hierarchical level' , ( async ( ) => {
884
924
// first level row
885
925
let dragIndicatorElement : Element = dragIndicatorElements [ 1 ] . nativeElement ;
886
926
let rowToDrag = dragGrid . getRowByIndex ( 0 ) ;
@@ -1138,6 +1178,57 @@ export class IgxHierarchicalGridTestComponent {
1138
1178
}
1139
1179
}
1140
1180
1181
+ @Component ( {
1182
+ template : `
1183
+ <igx-hierarchical-grid #hierarchicalDragGrid [data]="data"
1184
+ [autoGenerate]="true" [height]="'500px'" [width]="'1500px'"
1185
+ primaryKey="ID" [expandChildren]='true' [rowDraggable]="true">
1186
+ <igx-row-island [key]="'childData'" [expandChildren]='true' [autoGenerate]="true" [rowDraggable]="true" #rowIsland>
1187
+ <igx-row-island [key]="'childData2'" [autoGenerate]="true" [rowDraggable]="true" #rowIsland2 >
1188
+ </igx-row-island>
1189
+ <ng-template let-data igxRowDragGhost>
1190
+ <div>
1191
+ Moving {{data.ProductName}}!
1192
+ </div>
1193
+ </ng-template>
1194
+ </igx-row-island>
1195
+ <ng-template let-data igxRowDragGhost>
1196
+ <div>
1197
+ Moving {{data.ProductName}}!
1198
+ </div>
1199
+ </ng-template>
1200
+ </igx-hierarchical-grid>`
1201
+ } )
1202
+ export class IgxHierarchicalGridCustomGhostTestComponent {
1203
+ public data ;
1204
+ newData = [ ] ;
1205
+ @ViewChild ( 'hierarchicalDragGrid' , { read : IgxHierarchicalGridComponent , static : true } ) public hDragGrid : IgxHierarchicalGridComponent ;
1206
+ @ViewChild ( 'rowIsland' , { read : IgxRowIslandComponent , static : true } ) public rowIsland : IgxRowIslandComponent ;
1207
+ @ViewChild ( 'rowIsland2' , { read : IgxRowIslandComponent , static : true } ) public rowIsland2 : IgxRowIslandComponent ;
1208
+
1209
+ constructor ( ) {
1210
+ this . data = this . generateData ( 2 , 3 ) ;
1211
+ }
1212
+ generateData ( count : number , level : number ) {
1213
+ const prods = [ ] ;
1214
+ const currLevel = level ;
1215
+ let children ;
1216
+ for ( let i = 0 ; i < count ; i ++ ) {
1217
+ const item = {
1218
+ ID : i , ChildLevels : currLevel , ProductName : 'Product: A' + i , 'Col1' : i ,
1219
+ 'Col2' : i , 'Col3' : i
1220
+ } ;
1221
+ if ( currLevel > 1 ) {
1222
+ children = this . generateData ( count / 2 , currLevel - 1 ) ;
1223
+ const childProp = currLevel === 3 ? 'childData' : 'childData2' ;
1224
+ item [ childProp ] = children ;
1225
+ }
1226
+ prods . push ( item ) ;
1227
+ }
1228
+ return prods ;
1229
+ }
1230
+ }
1231
+
1141
1232
@Component ( {
1142
1233
template : `
1143
1234
<igx-tree-grid #treeGrid [data]="data" primaryKey="employeeID" foreignKey="PID" width="900px" height="500px" [rowDraggable]="true">
0 commit comments