Skip to content

Commit 9848e51

Browse files
authored
fix(grid): update ghost record handling for disabled rows - master (#16763)
1 parent 0446436 commit 9848e51

3 files changed

Lines changed: 20 additions & 2 deletions

File tree

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,12 @@ abstract class BaseRow implements RowType {
181181
return false;
182182
}
183183

184+
/**
185+
* Gets whether the row is disabled.
186+
* A disabled row represents a ghost placeholder created by row pinning.
187+
*/
184188
public get disabled(): boolean {
185-
return this.grid.isGhostRecord(this.data);
189+
return this.grid.isGhostRecordAtIndex(this.index);
186190
}
187191

188192
/**

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7878,8 +7878,10 @@ export abstract class IgxGridBaseDirective implements GridType,
78787878
* If record is pinned but is not in pinned area then it is a ghost record.
78797879
*
78807880
* @param dataViewIndex The index of that record in the data view.
7881+
* @hidden
7882+
* @internal
78817883
*/
7882-
private isGhostRecordAtIndex(dataViewIndex) {
7884+
public isGhostRecordAtIndex(dataViewIndex) {
78837885
const isPinned = this.isRecordPinned(this.dataView[dataViewIndex]);
78847886
const isInPinnedArea = this.isRecordPinnedByViewIndex(dataViewIndex);
78857887
return isPinned && !isInPinnedArea;

projects/igniteui-angular/grids/grid/src/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)