@@ -55,10 +55,10 @@ export class IgxPivotHeaderRowComponent extends IgxGridHeaderRowComponent {
5555 this . grid . pipeTrigger ++ ;
5656 }
5757
58- public onDimDragEnter ( event ) {
59- const isValue = this . grid . pivotConfiguration . values . find ( x => x . member === event . dragChip . id ) ;
60- if ( isValue ) {
61- // cannot drag value in dimensions
58+ public onDimDragEnter ( event , dimension : PivotDimensionType ) {
59+ const typeMismatch = dimension !== undefined ? this . grid . pivotConfiguration . values . find ( x => x . member === event . dragChip . id ) : null ;
60+ if ( typeMismatch ) {
61+ // cannot drag between dimensions and value
6262 return ;
6363 }
6464 event . owner . nativeElement . style . borderLeft = '1px solid red' ;
@@ -67,11 +67,11 @@ export class IgxPivotHeaderRowComponent extends IgxGridHeaderRowComponent {
6767 event . owner . nativeElement . style . borderLeft = '' ;
6868 }
6969
70- public onAreaDragEnter ( event , area ) {
70+ public onAreaDragEnter ( event , area , dimension : PivotDimensionType ) {
7171 const dragId = event . detail . owner . element . nativeElement . parentElement . id ;
72- const isValue = this . grid . pivotConfiguration . values . find ( x => x . member === dragId ) ;
73- if ( isValue ) {
74- // cannot drag value in dimensions
72+ const typeMismatch = dimension !== undefined ? this . grid . pivotConfiguration . values . find ( x => x . member === dragId ) : null ;
73+ if ( typeMismatch ) {
74+ // cannot drag between dimensions and value
7575 return ;
7676 }
7777 const lastElem = area . chipsList . last . nativeElement ;
@@ -87,6 +87,20 @@ export class IgxPivotHeaderRowComponent extends IgxGridHeaderRowComponent {
8787 } ) ;
8888 }
8989
90+ public onValueDrop ( event , area ) {
91+ //values can only be reordered
92+ const currentDim = this . grid . pivotConfiguration . values ;
93+ const dragId = event . dragChip ?. id || event . dragData ?. chip . id ;
94+ const chipsArray = area . chipsList . toArray ( ) ;
95+ const chipIndex = chipsArray . indexOf ( event . owner ) !== - 1 ? chipsArray . indexOf ( event . owner ) : chipsArray . length ;
96+ const newDim = currentDim . find ( x => x . member === dragId ) ;
97+ const dragChipIndex = chipsArray . indexOf ( event . dragChip || event . dragData . chip ) ;
98+ currentDim . splice ( dragChipIndex , 1 ) ;
99+ currentDim . splice ( dragChipIndex > chipIndex ? chipIndex : chipIndex - 1 , 0 , newDim ) ;
100+
101+ this . grid . setupColumns ( ) ;
102+ }
103+
90104 public onDimDrop ( event , area , dimension : PivotDimensionType ) {
91105 const dragId = event . dragChip ?. id || event . dragData ?. chip . id ;
92106 const currentDim = dimension === PivotDimensionType . Row ? this . grid . pivotConfiguration . rows :
0 commit comments