@@ -275,26 +275,19 @@ export class IgxPivotHeaderRowComponent extends IgxGridHeaderRowComponent {
275
275
. concat ( this . grid . pivotConfiguration . columns )
276
276
. concat ( this . grid . pivotConfiguration . filters ) ;
277
277
// chip moved from external collection
278
- const dims = allDims . filter ( x => x && x . memberName === dragId ) ;
279
- if ( dims . length === 0 ) {
278
+ const dim = allDims . find ( x => x && x . memberName === dragId ) ;
279
+ if ( ! dim ) {
280
280
// you have dragged something that is not a dimension
281
281
return ;
282
282
}
283
- dims . forEach ( element => {
284
- element . enabled = false ;
285
- } ) ;
283
+ const dimType = this . getDimensionsType ( dim ) ;
284
+
285
+ // Dragged chip from a different dimension to the current one.
286
+ const prevDimensionCollection = this . getDimensionsByType ( dimType ) ;
287
+ // delete from previous dimension collection and add to current.
288
+ prevDimensionCollection . splice ( prevDimensionCollection . indexOf ( dim ) , 1 ) ;
289
+ currentDim . splice ( targetIndex , 0 , dim ) ;
286
290
287
- const currentDimChild = currentDim . find ( x => x && x . memberName === dragId ) ;
288
- if ( currentDimChild ) {
289
- currentDimChild . enabled = true ;
290
- const dragChipIndex = currentDim . indexOf ( currentDimChild ) ;
291
- currentDim . splice ( dragChipIndex , 1 ) ;
292
- currentDim . splice ( dragChipIndex > chipIndex ? targetIndex : targetIndex - 1 , 0 , currentDimChild ) ;
293
- } else {
294
- const newDim = Object . assign ( { } , dims [ 0 ] ) ;
295
- newDim . enabled = true ;
296
- currentDim . splice ( targetIndex , 0 , newDim ) ;
297
- }
298
291
const isDraggedFromColumn = ! ! this . grid . pivotConfiguration . columns ?. find ( x => x && x . memberName === dragId ) ;
299
292
if ( isDraggedFromColumn ) {
300
293
// columns have changed.
@@ -341,6 +334,12 @@ export class IgxPivotHeaderRowComponent extends IgxGridHeaderRowComponent {
341
334
}
342
335
}
343
336
337
+ protected getDimensionsType ( dimension : IPivotDimension ) {
338
+ const isColumn = ! ! this . grid . pivotConfiguration . columns ?. find ( x => x && x . memberName === dimension . memberName ) ;
339
+ const isRow = ! ! this . grid . pivotConfiguration . rows ?. find ( x => x && x . memberName === dimension . memberName ) ;
340
+ return isColumn ? PivotDimensionType . Column : isRow ? PivotDimensionType . Row : PivotDimensionType . Filter ;
341
+ }
342
+
344
343
protected getAggregatorsForValue ( value : IPivotValue ) : IPivotAggregator [ ] {
345
344
const dataType = value . dataType || this . grid . resolveDataTypes ( this . grid . data [ 0 ] [ value . member ] ) ;
346
345
switch ( dataType ) {
0 commit comments