Skip to content

Commit 9711ee9

Browse files
committed
fix(pivotGrid): Update alt handling to take into account horizontal layout.
1 parent ab419a1 commit 9711ee9

File tree

2 files changed

+18
-15
lines changed

2 files changed

+18
-15
lines changed

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,18 +118,27 @@ export class IgxPivotGridNavigationService extends IgxGridNavigationService {
118118
public override handleAlt(key: string, event: KeyboardEvent): void {
119119
event.preventDefault();
120120

121-
const row = this.grid.gridAPI.get_row_by_index(this.activeNode.row);
122-
const expansionRowKey = PivotUtil.getRecordKey(row.data, row.data.dimensions[this.activeNode.column])
121+
const rowIndex = this.grid.hasHorizontalLayout ? this.activeNode.row + this.activeNode.layout.rowStart - 1 : this.activeNode.row
122+
const row = this.grid.gridAPI.get_row_by_index(rowIndex);
123+
const dimIndex = this.grid.hasHorizontalLayout ? this.activeNode.layout.colStart - 1 : this.activeNode.column;
124+
const expansionRowKey = PivotUtil.getRecordKey(row.data, this.grid.visibleRowDimensions[dimIndex]);
123125
const isExpanded = this.grid.expansionStates.get(expansionRowKey) ?? true;
124126

125127
if (ROW_EXPAND_KEYS.has(key) && !isExpanded) {
126128
this.grid.gridAPI.set_row_expansion_state(expansionRowKey, true, event)
127129
} else if (ROW_COLLAPSE_KEYS.has(key) && isExpanded) {
128130
this.grid.gridAPI.set_row_expansion_state(expansionRowKey, false, event)
129131
}
132+
this.updateActiveNodeLayout();
130133
this.grid.notifyChanges();
131134
}
132135

136+
public updateActiveNodeLayout() {
137+
const mrlRow = this.grid.rowDimensionMrlRowsCollection.toArray()[this.activeNode.row];
138+
const activeCell = mrlRow.contentCells.toArray()[this.activeNode.column];
139+
this.activeNode.layout = activeCell.layout;
140+
}
141+
133142
public override headerNavigation(event: KeyboardEvent) {
134143
const key = event.key.toLowerCase();
135144
const ctrl = event.ctrlKey;

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

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ export class PivotUtil {
122122
});
123123
}
124124

125-
const expansionRowKey = PivotUtil.getRecordKey(rec, dimension, true);
125+
const expansionRowKey = PivotUtil.getRecordKey(rec, dimension);
126126
const isExpanded = expansionStates.get(expansionRowKey) === undefined ?
127127
defaultExpand :
128128
expansionStates.get(expansionRowKey);
@@ -384,20 +384,14 @@ export class PivotUtil {
384384
return leafs;
385385
}
386386

387-
public static getRecordKey(rec: IPivotGridRecord, currentDim: IPivotDimension, horizontalLayout: boolean = false) {
387+
public static getRecordKey(rec: IPivotGridRecord, currentDim: IPivotDimension) {
388388
const parentFields = [];
389389

390-
if (!horizontalLayout) {
391-
const currentDimIndex = rec.dimensions.findIndex(x => x.memberName === currentDim.memberName) + 1;
392-
const prevDims = rec.dimensions.slice(0, currentDimIndex);
393-
for (const prev of prevDims) {
394-
const prevValue = rec.dimensionValues.get(prev.memberName);
395-
parentFields.push(prevValue);
396-
}
397-
} else {
398-
for(let i = 0; i < rec.dimensions.length; i++) {
399-
parentFields.push(rec.dimensionValues.get(rec.dimensions[i].memberName));
400-
}
390+
const currentDimIndex = rec.dimensions.findIndex(x => x.memberName === currentDim.memberName) + 1;
391+
const prevDims = rec.dimensions.slice(0, currentDimIndex);
392+
for (const prev of prevDims) {
393+
const prevValue = rec.dimensionValues.get(prev.memberName);
394+
parentFields.push(prevValue);
401395
}
402396

403397
return parentFields.join('-');

0 commit comments

Comments
 (0)