Skip to content

Commit

Permalink
fix(footer): usefix(footer): use getFilteredItemCount to show corre…
Browse files Browse the repository at this point in the history
…ct item count

- fixes Slickgrid-Universal issue [#469](ghiscoding/slickgrid-universal#469)
- we should always use DataView `getFilteredItemCount()` since that is really the item count that we want to show in the footer `getFilteredItemCount` to show correct count, fix #469
- fixes #469
- we should always use DataView `getFilteredItemCount()` since that is really the item count that we want to show in the footer
  • Loading branch information
ghiscoding committed Sep 7, 2021
1 parent 24674a6 commit fbee1a1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ const mockDataView = {
destroy: jest.fn(),
beginUpdate: jest.fn(),
endUpdate: jest.fn(),
getFilteredItemCount: jest.fn(),
getItem: jest.fn(),
getItems: jest.fn(),
getItemCount: jest.fn(),
Expand Down Expand Up @@ -1839,6 +1840,7 @@ describe('Angular-Slickgrid Custom Component instantiated via Constructor', () =
totalItemCount: 2
};
jest.spyOn(mockDataView, 'getItemCount').mockReturnValue(mockData.length);
jest.spyOn(mockDataView, 'getFilteredItemCount').mockReturnValue(mockData.length);

component.gridOptions = { enablePagination: false, showCustomFooter: true };
component.initialization(slickEventHandler);
Expand All @@ -1854,10 +1856,10 @@ describe('Angular-Slickgrid Custom Component instantiated via Constructor', () =
const expectation = {
startTime: expect.toBeDate(),
endTime: expect.toBeDate(),
itemCount: 2,
itemCount: 0,
totalItemCount: 0
};
jest.spyOn(mockDataView, 'getLength').mockReturnValue(2);
jest.spyOn(mockDataView, 'getFilteredItemCount').mockReturnValue(0);

component.gridOptions = { enablePagination: false, showCustomFooter: true };
component.initialization(slickEventHandler);
Expand Down Expand Up @@ -1885,6 +1887,7 @@ describe('Angular-Slickgrid Custom Component instantiated via Constructor', () =

component.gridOptions.enableCheckboxSelector = true;
component.gridOptions.presets = { rowSelection: { dataContextIds: selectedRowIds } };
component.isDatasetInitialized = false;
component.initialization(slickEventHandler);
component.dataset = mockData;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -923,11 +923,11 @@ export class AngularSlickgridComponent implements AfterViewInit, OnDestroy {
const onRowCountChangedHandler = dataView.onRowCountChanged;
(this._eventHandler as SlickEventHandler<GetSlickEventType<typeof onRowCountChangedHandler>>).subscribe(onRowCountChangedHandler, (_e, args) => {
grid.invalidate();
this.handleOnItemCountChanged(args.current || 0, dataView.getItemCount());
this.handleOnItemCountChanged(this.dataView.getFilteredItemCount() || 0, dataView.getItemCount());
});
const onSetItemsCalledHandler = dataView.onSetItemsCalled;
(this._eventHandler as SlickEventHandler<GetSlickEventType<typeof onSetItemsCalledHandler>>).subscribe(onSetItemsCalledHandler, (_e, args) => {
this.handleOnItemCountChanged(dataView.getLength(), args.itemCount);
this.handleOnItemCountChanged(this.dataView.getFilteredItemCount() || 0, args.itemCount);

// when user has resize by content enabled, we'll force a full width calculation since we change our entire dataset
if (args.itemCount > 0 && (this.gridOptions.autosizeColumnsByCellContentOnFirstLoad || this.gridOptions.enableAutoResizeColumnsByCellContent)) {
Expand Down

0 comments on commit fbee1a1

Please sign in to comment.