Skip to content

Commit 9bc0815

Browse files
Martin DragnevMartin Dragnev
Martin Dragnev
authored and
Martin Dragnev
committed
feat(igxGrid): Row Pinning + Paging integration #6640
1 parent ff2e0f6 commit 9bc0815

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

projects/igniteui-angular/src/lib/grids/grid/grid.pipes.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,10 @@ export class IgxGridPagingPipe implements PipeTransform {
103103
if (!this.gridAPI.grid.paging) {
104104
return collection;
105105
}
106-
106+
const _perPage = perPage - this.gridAPI.grid.pinnedRecords.length;
107107
const state = {
108108
index: page,
109-
recordsPerPage: perPage
109+
recordsPerPage: _perPage
110110
};
111111
DataUtil.correctPagingState(state, collection.data.length);
112112

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

+27
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,33 @@ describe('Row Pinning #grid', () => {
216216
expect(grid.getRowByIndex(0).rowID).toBe(fix.componentInstance.data[0]);
217217
expect(grid.getRowByIndex(1).rowID).toBe(fix.componentInstance.data[1]);
218218
});
219+
220+
it('should page through unpinned collection with modified pageSize = pageSize - pinnedRows.lenght.', () => {
221+
// pin 2nd row
222+
grid.paging = true;
223+
grid.perPage = 5;
224+
fix.detectChanges();
225+
let row = grid.getRowByIndex(1);
226+
row.pin();
227+
fix.detectChanges();
228+
229+
expect(grid.pinnedRecords.length).toBe(1);
230+
let pinRowContainer = fix.debugElement.queryAll(By.css(FIXED_ROW_CONTAINER));
231+
expect(pinRowContainer.length).toBe(1);
232+
233+
expect(grid.dataView.length).toBe(4);
234+
235+
// unpin
236+
row = grid.getRowByIndex(0);
237+
row.unpin();
238+
fix.detectChanges();
239+
240+
expect(grid.pinnedRecords.length).toBe(0);
241+
pinRowContainer = fix.debugElement.queryAll(By.css(FIXED_ROW_CONTAINER));
242+
expect(pinRowContainer.length).toBe(0);
243+
244+
expect(grid.dataView.length).toBe(5);
245+
});
219246
});
220247
});
221248

0 commit comments

Comments
 (0)