Skip to content

Commit e912471

Browse files
authored
fix(grid): update ghost record handling for disabled rows - 20.1.x (#16765)
1 parent 1623a70 commit e912471

3 files changed

Lines changed: 21 additions & 2 deletions

File tree

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7961,8 +7961,10 @@ export abstract class IgxGridBaseDirective implements GridType,
79617961
* If record is pinned but is not in pinned area then it is a ghost record.
79627962
*
79637963
* @param dataViewIndex The index of that record in the data view.
7964+
* @hidden
7965+
* @internal
79647966
*/
7965-
private isGhostRecordAtIndex(dataViewIndex) {
7967+
public isGhostRecordAtIndex(dataViewIndex) {
79667968
const isPinned = this.isRecordPinned(this.dataView[dataViewIndex]);
79677969
const isInPinnedArea = this.isRecordPinnedByViewIndex(dataViewIndex);
79687970
return isPinned && !isInPinnedArea;

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { IgxPivotGridComponent } from './pivot-grid/pivot-grid.component';
88
import { PivotUtil } from './pivot-grid/pivot-util';
99
import { mergeWith } from 'lodash-es';
1010
import { CellType, GridServiceType, GridType, IGridValidationState, RowType, ValidationStatus } from './common/grid.interface';
11+
import { IgxGridComponent } from './grid/grid.component';
1112

1213
abstract class BaseRow implements RowType {
1314
public index: number;
@@ -185,8 +186,12 @@ abstract class BaseRow implements RowType {
185186
return false;
186187
}
187188

189+
/**
190+
* Gets whether the row is disabled.
191+
* A disabled row represents a ghost placeholder created by row pinning.
192+
*/
188193
public get disabled(): boolean {
189-
return this.grid.isGhostRecord(this.data);
194+
return (this.grid as IgxGridComponent).isGhostRecordAtIndex(this.index);
190195
}
191196

192197
/**

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,18 @@ describe('Row Pinning #grid', () => {
397397
expect(grid.gridAPI.get_row_by_index(1).key).toBe(fix.componentInstance.data[1]);
398398
});
399399

400+
it('should mark ghost placeholder rows as disabled in RowType API.', () => {
401+
grid.pinRow(fix.componentInstance.data[0]);
402+
fix.detectChanges();
403+
404+
const renderedRow = grid.rowList.toArray().find(r => r.index === 1);
405+
const rowType = grid.getRowByIndex(1);
406+
407+
expect(renderedRow).toBeDefined();
408+
expect(renderedRow.disabled).toBeTrue();
409+
expect(rowType.disabled).toBeTrue();
410+
});
411+
400412
it('should search in both pinned and unpinned rows.', () => {
401413
// pin 1st row
402414
let row = grid.gridAPI.get_row_by_index(0);

0 commit comments

Comments
 (0)