Skip to content

Commit

Permalink
fix(pagination): on filter change pagination should reset to 1st page (
Browse files Browse the repository at this point in the history
…#397)

- when using local grid, the DataView should be reset to page 0
  • Loading branch information
ghiscoding committed Feb 5, 2020
1 parent 3139660 commit af64dd6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,18 @@ describe('PaginationService', () => {

expect(spy).toHaveBeenCalledWith(true, false);
});

it('should reset the DataView when using local grid by calling "setPagingOptions" with page 0 and also call "refreshPagination" method', () => {
const spy = jest.spyOn(service, 'refreshPagination');
const setPagingSpy = jest.spyOn(dataviewStub, 'setPagingOptions');

mockGridOption.backendServiceApi = null;
service.init(gridStub, dataviewStub, mockGridOption.pagination, null);
service.resetPagination();

expect(setPagingSpy).toHaveBeenCalledWith({ pageSize: 25, pageNum: 0 });
expect(spy).toHaveBeenCalledWith(true, true);
});
});

// processOnItemAddedOrRemoved is private but we can spy on recalculateFromToIndexes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,10 @@ export class PaginationService {

/** Reset the Pagination to first page and recalculate necessary numbers */
resetPagination(triggerChangedEvent = true) {
if (this._isLocalGrid) {
// on a local grid we also need to reset the DataView paging to 1st page
this.dataView.setPagingOptions({ pageSize: this._itemsPerPage, pageNum: 0 });
}
this.refreshPagination(true, triggerChangedEvent);
}

Expand Down

0 comments on commit af64dd6

Please sign in to comment.