Skip to content

Commit ec7c0f2

Browse files
MKirovaMKirova
authored andcommitted
Additional fixes for reorder scenarios.
1 parent 9e989c8 commit ec7c0f2

File tree

4 files changed

+25
-13
lines changed

4 files changed

+25
-13
lines changed

projects/igniteui-angular/src/lib/grids/pivot-grid/pivot-grid.pipes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export class IgxPivotRowExpansionPipe implements PipeTransform {
4949
_pipeTrigger?: number,
5050
pivotKeys: IPivotKeys = {aggregations: 'aggregations', records: 'records', children: 'children', level: 'level'}
5151
): any[] {
52-
const data = collection.slice(0);
52+
const data = collection ? collection.slice(0) : [];
5353
let totalLlv = 0;
5454
const prevDims = [];
5555
for (const row of config.rows) {

projects/igniteui-angular/src/lib/grids/pivot-grid/pivot-header-row.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@
117117
<ng-template igxGridFor #headerVirtualContainer let-column
118118
[igxGridForOf]="unpinnedColumnCollection | igxTopLevel"
119119
[igxForScrollContainer]="grid.parentVirtDir"
120-
[igxForContainerSize]="grid.unpinnedWidth"
120+
[igxForContainerSize]=" row ? grid.pivotRowWidths : grid.unpinnedWidth"
121121
[igxForTrackBy]="grid.trackColumnChanges"
122122
[igxForSizePropName]="'calcPixelWidth'"
123123
[igxForScrollOrientation]="'horizontal'"

projects/igniteui-angular/src/lib/grids/pivot-grid/pivot-header-row.component.ts

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -135,32 +135,44 @@ export class IgxPivotHeaderRowComponent extends IgxGridHeaderRowComponent {
135135
const chipsArray = area.chipsList.toArray();
136136
const chip = chipsArray.find(x => x.id === dragId);
137137
const isNewChip = chip === undefined;
138-
const chipIndex = chipsArray.indexOf(event.owner) !== -1 ? chipsArray.indexOf(event.owner) : chipsArray.length;
138+
//const chipIndex = chipsArray.indexOf(event.owner) !== -1 ? chipsArray.indexOf(event.owner) : chipsArray.length;
139+
const chipIndex = currentDim.findIndex(x => x.fieldName === event.owner.id) !== -1 ?
140+
currentDim.findIndex(x => x.fieldName === event.owner.id) : currentDim.length;
139141
if (isNewChip) {
140142
const allDims = this.grid.pivotConfiguration.rows
141143
.concat(this.grid.pivotConfiguration.columns)
142144
.concat(this.grid.pivotConfiguration.filters);
143145
// chip moved from external collection
144-
const dim = allDims.find(x => x && x.fieldName === dragId);
145-
if (!dim) {
146+
const dims = allDims.filter(x => x && x.fieldName === dragId);
147+
if (dims.length === 0) {
146148
// you have dragged something that is not a dimension
147149
return;
148150
}
149-
dim.enabled = false;
151+
dims.forEach(element => {
152+
element.enabled = false;
153+
});
154+
155+
const currentDimChild = currentDim.find(x => x && x.fieldName === dragId);
156+
if (currentDimChild) {
157+
currentDimChild.enabled = true;
158+
const dragChipIndex = currentDim.indexOf(currentDimChild);
159+
currentDim.splice(dragChipIndex, 1);
160+
currentDim.splice(dragChipIndex > chipIndex ? chipIndex : chipIndex - 1, 0, currentDimChild);
161+
} else {
162+
const newDim = Object.assign({}, dims[0]);
163+
newDim.enabled = true;
164+
currentDim.splice(chipIndex, 0, newDim);
165+
}
150166
const isDraggedFromColumn = !!this.grid.pivotConfiguration.columns?.find(x => x && x.fieldName === dragId);
151167
if (isDraggedFromColumn) {
152168
// columns have changed.
153169
this.grid.setupColumns();
154170
}
155-
156-
const newDim = Object.assign({}, dim);
157-
newDim.enabled = true;
158-
currentDim.splice(chipIndex, 0, newDim);
159-
160171
} else {
161172
// chip from same collection, reordered.
162173
const newDim = currentDim.find(x => x.fieldName === dragId);
163-
const dragChipIndex = chipsArray.indexOf(event.dragChip || event.dragData.chip);
174+
//const dragChipIndex = chipsArray.indexOf(event.dragChip || event.dragData.chip);
175+
const dragChipIndex = currentDim.findIndex(x => x.fieldName === dragId);
164176
currentDim.splice(dragChipIndex, 1);
165177
currentDim.splice(dragChipIndex > chipIndex ? chipIndex : chipIndex - 1, 0, newDim);
166178
}

projects/igniteui-angular/src/lib/grids/pivot-grid/pivot-row.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export class IgxPivotRowComponent extends IgxRowDirective<IgxPivotGridComponent>
8383
if (changes.rowData) {
8484
// generate new rowDimension on row data change
8585
this.rowDimension = [];
86-
const rowDimConfig = this.grid.pivotConfiguration.rows;
86+
const rowDimConfig = this.grid.rowDimensions;
8787
this.extractFromDimensions(rowDimConfig, 0);
8888
}
8989
}

0 commit comments

Comments
 (0)