Skip to content

Commit 8a48522

Browse files
authored
Merge pull request #6869 from IgniteUI/sstoychev/mrl-next-prev-cell-90
fix(mrl): fixing validPosition for mrl and right pinning scenarios #6745 - 9.0
2 parents db4449c + 5546d7d commit 8a48522

File tree

2 files changed

+31
-3
lines changed

2 files changed

+31
-3
lines changed

projects/igniteui-angular/src/lib/grids/grid-base.directive.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5293,10 +5293,10 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
52935293

52945294
private isValidPosition(rowIndex, colIndex): boolean {
52955295
const rows = this.summariesRowList.filter(s => s.index !== 0).concat(this.rowList.toArray()).length;
5296-
const cols = this.columnList.filter(col => !col.columnGroup && col.visibleIndex >= 0).length;
5296+
const cols = this.columnList.filter(col => !col.columnGroup && col.visibleIndex >= 0 && !col.hidden).length;
52975297
if (rows < 1 || cols < 1) { return false; }
52985298
if (rowIndex > -1 && rowIndex < this.dataView.length &&
5299-
colIndex > - 1 && colIndex <= this.unpinnedColumns[this.unpinnedColumns.length - 1].visibleIndex) {
5299+
colIndex > - 1 && colIndex < cols) {
53005300
return true;
53015301
}
53025302
return false;

projects/igniteui-angular/src/lib/grids/grid/grid.multi-row-layout.spec.ts

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { wait } from '../../test-utils/ui-interactions.spec';
1111
import { DefaultSortingStrategy } from '../../data-operations/sorting-strategy';
1212
import { configureTestSuite } from '../../test-utils/configure-suite';
1313
import { verifyLayoutHeadersAreAligned, verifyDOMMatchesLayoutSettings } from '../../test-utils/helper-utils.spec';
14+
import { ICellPosition } from '../common/events';
1415

1516

1617
const GRID_COL_THEAD_TITLE_CLASS = 'igx-grid__th-title';
@@ -1174,6 +1175,33 @@ describe('IgxGrid - multi-row-layout #grid', () => {
11741175
expect(col.hidden).toBe(false);
11751176
expect(col.parent.hidden).toBe(false);
11761177
});
1178+
1179+
it('should get the correct next and previous cell when in MRL scenario', () => {
1180+
const fixture = TestBed.createComponent(ColumnLayoutTestComponent);
1181+
fixture.componentInstance.colGroups = [{
1182+
group: 'group1',
1183+
columns: [
1184+
{ field: 'CompanyName', rowStart: 1, rowEnd: 2, colStart: 3, colEnd: 4, dataType: 'number', editable: true },
1185+
{ field: 'ID', rowStart: 1, rowEnd: 2, colStart: 1, colEnd: 2, dataType: 'number', editable: false },
1186+
{ field: 'ContactName', rowStart: 1, rowEnd: 2, colStart: 2, colEnd: 3, dataType: 'string', editable: false },
1187+
]
1188+
}];
1189+
const grid = fixture.componentInstance.grid;
1190+
fixture.detectChanges();
1191+
let pos: ICellPosition;
1192+
pos = grid.getNextCell(0, 1, col => col.editable === true);
1193+
expect(pos.rowIndex).toEqual(0);
1194+
expect(pos.visibleColumnIndex).toEqual(2);
1195+
pos = grid.getNextCell(0, 2, col => col.editable === true);
1196+
expect(pos.rowIndex).toEqual(1);
1197+
expect(pos.visibleColumnIndex).toEqual(2);
1198+
pos = grid.getPreviousCell(1, 2);
1199+
expect(pos.rowIndex).toEqual(1);
1200+
expect(pos.visibleColumnIndex).toEqual(1);
1201+
pos = grid.getPreviousCell(1, 2, col => col.editable === true);
1202+
expect(pos.rowIndex).toEqual(0);
1203+
expect(pos.visibleColumnIndex).toEqual(2);
1204+
});
11771205
});
11781206

11791207
@Component({
@@ -1182,7 +1210,7 @@ describe('IgxGrid - multi-row-layout #grid', () => {
11821210
<igx-column-layout *ngFor='let group of colGroups'>
11831211
<igx-column *ngFor='let col of group.columns'
11841212
[rowStart]="col.rowStart" [colStart]="col.colStart" [width]='col.width'
1185-
[colEnd]="col.colEnd" [rowEnd]="col.rowEnd" [field]='col.field'></igx-column>
1213+
[colEnd]="col.colEnd" [rowEnd]="col.rowEnd" [field]='col.field' [editable]='col.editable'></igx-column>
11861214
</igx-column-layout>
11871215
</igx-grid>
11881216
`

0 commit comments

Comments
 (0)