@@ -275,25 +275,23 @@ 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
- } ) ;
286
-
283
+ const dimType = this . getDimensionsType ( dim ) ;
287
284
const currentDimChild = currentDim . find ( x => x && x . memberName === dragId ) ;
288
285
if ( currentDimChild ) {
289
286
currentDimChild . enabled = true ;
290
287
const dragChipIndex = currentDim . indexOf ( currentDimChild ) ;
291
288
currentDim . splice ( dragChipIndex , 1 ) ;
292
289
currentDim . splice ( dragChipIndex > chipIndex ? targetIndex : targetIndex - 1 , 0 , currentDimChild ) ;
293
290
} else {
294
- const newDim = Object . assign ( { } , dims [ 0 ] ) ;
295
- newDim . enabled = true ;
296
- currentDim . splice ( targetIndex , 0 , newDim ) ;
291
+ const prevDimensionCollection = this . getDimensionsByType ( dimType ) ;
292
+ // delete from previous dimension collection and add to current.
293
+ prevDimensionCollection . splice ( prevDimensionCollection . indexOf ( dim ) , 1 ) ;
294
+ currentDim . splice ( targetIndex , 0 , dim ) ;
297
295
}
298
296
const isDraggedFromColumn = ! ! this . grid . pivotConfiguration . columns ?. find ( x => x && x . memberName === dragId ) ;
299
297
if ( isDraggedFromColumn ) {
@@ -341,6 +339,12 @@ export class IgxPivotHeaderRowComponent extends IgxGridHeaderRowComponent {
341
339
}
342
340
}
343
341
342
+ protected getDimensionsType ( dimension : IPivotDimension ) {
343
+ const isColumn = ! ! this . grid . pivotConfiguration . columns ?. find ( x => x && x . memberName === dimension . memberName ) ;
344
+ const isRow = ! ! this . grid . pivotConfiguration . rows ?. find ( x => x && x . memberName === dimension . memberName ) ;
345
+ return isColumn ? PivotDimensionType . Column : isRow ? PivotDimensionType . Row : PivotDimensionType . Filter ;
346
+ }
347
+
344
348
protected getAggregatorsForValue ( value : IPivotValue ) : IPivotAggregator [ ] {
345
349
const dataType = value . dataType || this . grid . resolveDataTypes ( this . grid . data [ 0 ] [ value . member ] ) ;
346
350
switch ( dataType ) {
0 commit comments