@@ -275,26 +275,19 @@ export class IgxPivotHeaderRowComponent extends IgxGridHeaderRowComponent {
275275 . concat ( this . grid . pivotConfiguration . columns )
276276 . concat ( this . grid . pivotConfiguration . filters ) ;
277277 // 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 ) {
280280 // you have dragged something that is not a dimension
281281 return ;
282282 }
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 ) ;
286290
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- }
298291 const isDraggedFromColumn = ! ! this . grid . pivotConfiguration . columns ?. find ( x => x && x . memberName === dragId ) ;
299292 if ( isDraggedFromColumn ) {
300293 // columns have changed.
@@ -341,6 +334,12 @@ export class IgxPivotHeaderRowComponent extends IgxGridHeaderRowComponent {
341334 }
342335 }
343336
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+
344343 protected getAggregatorsForValue ( value : IPivotValue ) : IPivotAggregator [ ] {
345344 const dataType = value . dataType || this . grid . resolveDataTypes ( this . grid . data [ 0 ] [ value . member ] ) ;
346345 switch ( dataType ) {
0 commit comments