Skip to content

Commit 40c23d1

Browse files
committed
chore(*): allowing pinning on init, adding test
1 parent 1a84fae commit 40c23d1

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

projects/igniteui-angular/src/lib/grids/api.service.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ export class GridBaseAPIService <T extends IgxGridBaseDirective & GridType> {
8686
}
8787

8888
public get_row_by_key(rowSelector: any): IgxRowDirective<IgxGridBaseDirective & GridType> {
89+
if (!this.grid) {
90+
return null;
91+
}
8992
const primaryKey = this.grid.primaryKey;
9093
if (primaryKey !== undefined && primaryKey !== null) {
9194
return this.grid.dataRowList.find((row) => row.rowData[primaryKey] === rowSelector);

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,17 @@ describe('Row Pinning #grid', () => {
223223
expect(grid.getRowByIndex(1).rowID).toBe(fix.componentInstance.data[1]);
224224
});
225225

226+
it('should allow pinning onInit', () => {
227+
expect(() => {
228+
fix = TestBed.createComponent(GridRowPinningComponent);
229+
grid = fix.componentInstance.instance;
230+
grid.pinRow(fix.componentInstance.data[1]);
231+
fix.detectChanges();
232+
}).not.toThrow();
233+
expect(grid.pinnedRows.length).toBe(1);
234+
expect(grid.getRowByIndex(0).rowID).toBe(fix.componentInstance.data[1]);
235+
});
236+
226237
it('should pin rows when columns are grouped.', () => {
227238
grid.height = '550px';
228239
fix.detectChanges();

0 commit comments

Comments
 (0)