diff --git a/packages/common/src/filters/__tests__/compoundInputFilter.spec.ts b/packages/common/src/filters/__tests__/compoundInputFilter.spec.ts index 1ba324a70..2d4a64dce 100644 --- a/packages/common/src/filters/__tests__/compoundInputFilter.spec.ts +++ b/packages/common/src/filters/__tests__/compoundInputFilter.spec.ts @@ -85,7 +85,7 @@ describe('CompoundInputFilter', () => { const filterInputElm = divContainer.querySelector('.search-filter.filter-duration input') as HTMLInputElement; filterInputElm.focus(); - filterInputElm.dispatchEvent(new (window.window as any).Event('input', { key: 'a', keyCode: 97, bubbles: true, cancelable: true })); + filterInputElm.dispatchEvent(new (window.window as any).Event('keyup', { key: 'a', keyCode: 97, bubbles: true, cancelable: true })); const filterFilledElms = divContainer.querySelectorAll('.search-filter.filter-duration.filled'); expect(filterFilledElms.length).toBe(1); @@ -109,23 +109,6 @@ describe('CompoundInputFilter', () => { expect(spyCallback).toHaveBeenCalledWith(expect.anything(), { columnDef: mockColumn, operator: '', searchTerms: ['abc'], shouldTriggerQuery: true }); }); - it('should call "setValues" and expect that value NOT to be in the callback when triggered by a keyup event that is NOT the ENTER key', () => { - const spyCallback = jest.spyOn(filterArguments, 'callback'); - - filter.init(filterArguments); - filter.setValues(['abc']); - const filterInputElm = divContainer.querySelector('.search-filter.filter-duration input') as HTMLInputElement; - - filterInputElm.focus(); - const event = new (window.window as any).Event('keyup', { bubbles: true, cancelable: true }); - event.key = 'a'; - filterInputElm.dispatchEvent(event); - const filterFilledElms = divContainer.querySelectorAll('.search-filter.filter-duration.filled'); - - expect(filterFilledElms.length).toBe(0); - expect(spyCallback).not.toHaveBeenCalled(); - }); - it('should call "setValues" with "operator" set in the filter arguments and expect that value to be in the callback when triggered', () => { mockColumn.type = FieldType.number; const filterArgs = { ...filterArguments, operator: '>' } as FilterArguments; @@ -136,7 +119,7 @@ describe('CompoundInputFilter', () => { const filterInputElm = divContainer.querySelector('.search-filter.filter-duration input') as HTMLInputElement; filterInputElm.focus(); - filterInputElm.dispatchEvent(new (window.window as any).Event('input', { key: 'a', keyCode: 97, bubbles: true, cancelable: true })); + filterInputElm.dispatchEvent(new (window.window as any).Event('keyup', { key: 'a', keyCode: 97, bubbles: true, cancelable: true })); expect(spyCallback).toHaveBeenCalledWith(expect.anything(), { columnDef: mockColumn, operator: '>', searchTerms: ['9'], shouldTriggerQuery: true }); }); @@ -180,7 +163,7 @@ describe('CompoundInputFilter', () => { const filterInputElm = divContainer.querySelector('.search-filter.filter-duration input') as HTMLInputElement; filterInputElm.focus(); - filterInputElm.dispatchEvent(new (window.window as any).Event('input', { key: 'a', keyCode: 97, bubbles: true, cancelable: true })); + filterInputElm.dispatchEvent(new (window.window as any).Event('keyup', { key: 'a', keyCode: 97, bubbles: true, cancelable: true })); expect(spyCallback).toHaveBeenCalledWith(expect.anything(), { columnDef: mockColumn, operator: '>', searchTerms: ['987'], shouldTriggerQuery: true }); }); @@ -197,7 +180,7 @@ describe('CompoundInputFilter', () => { const filterInputElm = divContainer.querySelector('.search-filter.filter-duration input') as HTMLInputElement; filterInputElm.focus(); - filterInputElm.dispatchEvent(new (window.window as any).Event('input', { key: 'a', keyCode: 97, bubbles: true, cancelable: true })); + filterInputElm.dispatchEvent(new (window.window as any).Event('keyup', { key: 'a', keyCode: 97, bubbles: true, cancelable: true })); expect(spyCallback).toHaveBeenCalledWith(expect.anything(), { columnDef: mockColumn, operator: '>', searchTerms: ['987'], shouldTriggerQuery: true }); }); @@ -210,7 +193,7 @@ describe('CompoundInputFilter', () => { filterInputElm.focus(); filterInputElm.value = 'a'; - filterInputElm.dispatchEvent(new (window.window as any).Event('input', { key: 'a', keyCode: 97, bubbles: true, cancelable: true })); + filterInputElm.dispatchEvent(new (window.window as any).Event('keyup', { key: 'a', keyCode: 97, bubbles: true, cancelable: true })); expect(spyCallback).toHaveBeenCalledWith(expect.anything(), { columnDef: mockColumn, operator: '', searchTerms: ['a'], shouldTriggerQuery: true }); }); @@ -224,7 +207,7 @@ describe('CompoundInputFilter', () => { filterInputElm.focus(); filterInputElm.value = 'a'; - filterInputElm.dispatchEvent(new (window.window as any).Event('input', { key: 'a', keyCode: 97, bubbles: true, cancelable: true })); + filterInputElm.dispatchEvent(new (window.window as any).Event('keyup', { key: 'a', keyCode: 97, bubbles: true, cancelable: true })); setTimeout(() => { expect(spyCallback).toHaveBeenCalledWith(expect.anything(), { columnDef: mockColumn, operator: '', searchTerms: ['a'], shouldTriggerQuery: true }); @@ -245,7 +228,7 @@ describe('CompoundInputFilter', () => { filterInputElm.focus(); filterInputElm.value = 'a'; - filterInputElm.dispatchEvent(new (window.window as any).Event('input', { key: 'a', keyCode: 97, bubbles: true, cancelable: true })); + filterInputElm.dispatchEvent(new (window.window as any).Event('keyup', { key: 'a', keyCode: 97, bubbles: true, cancelable: true })); setTimeout(() => { expect(spyCallback).toHaveBeenCalledWith(expect.anything(), { columnDef: mockColumn, operator: '', searchTerms: ['a'], shouldTriggerQuery: true }); diff --git a/packages/common/src/filters/__tests__/inputFilter.spec.ts b/packages/common/src/filters/__tests__/inputFilter.spec.ts index aa7dae6d9..b2e7f71fa 100644 --- a/packages/common/src/filters/__tests__/inputFilter.spec.ts +++ b/packages/common/src/filters/__tests__/inputFilter.spec.ts @@ -77,7 +77,7 @@ describe('InputFilter', () => { const filterElm = divContainer.querySelector('input.filter-duration') as HTMLInputElement; filterElm.focus(); - filterElm.dispatchEvent(new (window.window as any).Event('input', { key: 'a', keyCode: 97, bubbles: true, cancelable: true })); + filterElm.dispatchEvent(new (window.window as any).Event('keyup', { key: 'a', keyCode: 97, bubbles: true, cancelable: true })); const filterFilledElms = divContainer.querySelectorAll('input.filter-duration.filled'); expect(filterFilledElms.length).toBe(1); @@ -101,23 +101,6 @@ describe('InputFilter', () => { expect(spyCallback).toHaveBeenCalledWith(expect.anything(), { columnDef: mockColumn, operator: '', searchTerms: ['abc'], shouldTriggerQuery: true }); }); - it('should call "setValues" and expect that value NOT to be in the callback when triggered by a keyup event that is NOT the ENTER key', () => { - const spyCallback = jest.spyOn(filterArguments, 'callback'); - - filter.init(filterArguments); - filter.setValues('abc'); - const filterElm = divContainer.querySelector('input.filter-duration') as HTMLInputElement; - - filterElm.focus(); - const event = new (window.window as any).Event('keyup', { bubbles: true, cancelable: true }); - event.key = 'a'; - filterElm.dispatchEvent(event); - const filterFilledElms = divContainer.querySelectorAll('input.filter-duration.filled'); - - expect(filterFilledElms.length).toBe(0); - expect(spyCallback).not.toHaveBeenCalled(); - }); - it('should call "setValues" with an operator and with extra spaces at the beginning of the searchTerms and trim value when "enableFilterTrimWhiteSpace" is enabled in grid options', () => { gridOptionMock.enableFilterTrimWhiteSpace = true; const spyCallback = jest.spyOn(filterArguments, 'callback'); @@ -127,7 +110,7 @@ describe('InputFilter', () => { const filterElm = divContainer.querySelector('input.filter-duration') as HTMLInputElement; filterElm.focus(); - filterElm.dispatchEvent(new (window.window as any).Event('input', { key: 'a', keyCode: 97, bubbles: true, cancelable: true })); + filterElm.dispatchEvent(new (window.window as any).Event('keyup', { key: 'a', keyCode: 97, bubbles: true, cancelable: true })); const filterFilledElms = divContainer.querySelectorAll('input.filter-duration.filled'); expect(filterFilledElms.length).toBe(1); @@ -144,7 +127,7 @@ describe('InputFilter', () => { const filterElm = divContainer.querySelector('input.filter-duration') as HTMLInputElement; filterElm.focus(); - filterElm.dispatchEvent(new (window.window as any).Event('input', { key: 'a', keyCode: 97, bubbles: true, cancelable: true })); + filterElm.dispatchEvent(new (window.window as any).Event('keyup', { key: 'a', keyCode: 97, bubbles: true, cancelable: true })); const filterFilledElms = divContainer.querySelectorAll('input.filter-duration.filled'); expect(filterFilledElms.length).toBe(1); @@ -159,7 +142,7 @@ describe('InputFilter', () => { filterElm.focus(); filterElm.value = 'a'; - filterElm.dispatchEvent(new (window.window as any).Event('input', { key: 'a', keyCode: 97, bubbles: true, cancelable: true })); + filterElm.dispatchEvent(new (window.window as any).Event('keyup', { key: 'a', keyCode: 97, bubbles: true, cancelable: true })); expect(spyCallback).toHaveBeenCalledWith(expect.anything(), { columnDef: mockColumn, operator: 'EQ', searchTerms: ['a'], shouldTriggerQuery: true }); }); @@ -173,7 +156,7 @@ describe('InputFilter', () => { filterElm.focus(); filterElm.value = 'a'; - filterElm.dispatchEvent(new (window.window as any).Event('input', { key: 'a', keyCode: 97, bubbles: true, cancelable: true })); + filterElm.dispatchEvent(new (window.window as any).Event('keyup', { key: 'a', keyCode: 97, bubbles: true, cancelable: true })); setTimeout(() => { expect(spyCallback).toHaveBeenCalledWith(expect.anything(), { columnDef: mockColumn, operator: 'EQ', searchTerms: ['a'], shouldTriggerQuery: true }); @@ -193,7 +176,7 @@ describe('InputFilter', () => { filterElm.focus(); filterElm.value = 'a'; - filterElm.dispatchEvent(new (window.window as any).Event('input', { key: 'a', keyCode: 97, bubbles: true, cancelable: true })); + filterElm.dispatchEvent(new (window.window as any).Event('keyup', { key: 'a', keyCode: 97, bubbles: true, cancelable: true })); setTimeout(() => { expect(spyCallback).toHaveBeenCalledWith(expect.anything(), { columnDef: mockColumn, operator: 'EQ', searchTerms: ['a'], shouldTriggerQuery: true }); diff --git a/packages/common/src/filters/compoundInputFilter.ts b/packages/common/src/filters/compoundInputFilter.ts index 511612cdf..164ab8de5 100644 --- a/packages/common/src/filters/compoundInputFilter.ts +++ b/packages/common/src/filters/compoundInputFilter.ts @@ -99,7 +99,8 @@ export class CompoundInputFilter implements Filter { // step 3, subscribe to the input change event and run the callback when that happens // also add/remove "filled" class for styling purposes - this.$filterInputElm.on('keyup input blur', this.onTriggerEvent.bind(this)); + // we'll use all necessary events to cover the following (keyup, change, mousewheel & spinner) + this.$filterInputElm.on('keyup blur change wheel', this.onTriggerEvent.bind(this)); this.$selectOperatorElm.on('change', this.onTriggerEvent.bind(this)); } @@ -122,7 +123,7 @@ export class CompoundInputFilter implements Filter { */ destroy() { if (this.$filterElm && this.$selectOperatorElm) { - this.$filterElm.off('keyup input').remove(); + this.$filterElm.off('keyup blur change wheel').remove(); this.$selectOperatorElm.off('change'); } this.$filterElm = null; @@ -252,17 +253,16 @@ export class CompoundInputFilter implements Filter { return $filterContainerElm; } - /** Event trigger, could be called by the Operator dropdown or the input itself */ + /** + * Event trigger, could be called by the Operator dropdown or the input itself and we will cover the following (keyup, change, mousewheel & spinner) + * We will trigger the Filter Service callback from this handler + */ protected onTriggerEvent(event: KeyboardEvent | undefined) { - // we'll use the "input" event for everything (keyup, change, mousewheel & spinner) - // with 1 small exception, we need to use the keyup event to handle ENTER key, everything will be processed by the "input" event - if (event && event.type === 'keyup' && event.key !== 'Enter') { - return; - } if (this._clearFilterTriggered) { this.callback(event, { columnDef: this.columnDef, clearFilterTriggered: this._clearFilterTriggered, shouldTriggerQuery: this._shouldTriggerQuery }); this.$filterElm.removeClass('filled'); } else { + const eventType = event?.type ?? ''; const selectedOperator = this.$selectOperatorElm.find('option:selected').val(); let value = this.$filterInputElm.val() as string; const enableWhiteSpaceTrim = this.gridOptions.enableFilterTrimWhiteSpace || this.columnFilter.enableTrimWhiteSpace; @@ -272,7 +272,7 @@ export class CompoundInputFilter implements Filter { (value !== null && value !== undefined && value !== '') ? this.$filterElm.addClass('filled') : this.$filterElm.removeClass('filled'); const callbackArgs = { columnDef: this.columnDef, searchTerms: (value ? [value] : null), operator: selectedOperator || '', shouldTriggerQuery: this._shouldTriggerQuery }; - const typingDelay = (event?.key === 'Enter' || event?.type === 'blur') ? 0 : this._debounceTypingDelay; + const typingDelay = (eventType === 'keyup' && event?.key !== 'Enter') ? this._debounceTypingDelay : 0; if (typingDelay > 0) { clearTimeout(this.timer as NodeJS.Timeout); diff --git a/packages/common/src/filters/inputFilter.ts b/packages/common/src/filters/inputFilter.ts index e7d39a1c5..235ae782a 100644 --- a/packages/common/src/filters/inputFilter.ts +++ b/packages/common/src/filters/inputFilter.ts @@ -88,7 +88,8 @@ export class InputFilter implements Filter { // step 3, subscribe to the input event and run the callback when that happens // also add/remove "filled" class for styling purposes - this.$filterElm.on('keyup input blur', this.handleInputChange.bind(this)); + // we'll use all necessary events to cover the following (keyup, change, mousewheel & spinner) + this.$filterElm.on('keyup blur change wheel', this.handleInputChange.bind(this)); } /** @@ -100,7 +101,7 @@ export class InputFilter implements Filter { this._shouldTriggerQuery = shouldTriggerQuery; this.searchTerms = []; this.$filterElm.val(''); - this.$filterElm.trigger('input'); + this.$filterElm.trigger('change'); } } @@ -109,7 +110,7 @@ export class InputFilter implements Filter { */ destroy() { if (this.$filterElm) { - this.$filterElm.off('keyup input').remove(); + this.$filterElm.off('keyup blur change wheel').remove(); } this.$filterElm = null; } @@ -168,17 +169,16 @@ export class InputFilter implements Filter { return $filterElm; } + /** + * Event handler to cover the following (keyup, change, mousewheel & spinner) + * We will trigger the Filter Service callback from this handler + */ protected handleInputChange(event: KeyboardEvent & { target: any; }) { - // we'll use the "input" event for everything (keyup, change, mousewheel & spinner) - // with 1 small exception, we need to use the keyup event to handle ENTER key, everything will be processed by the "input" event - if (event && event.type === 'keyup' && event.key !== 'Enter') { - return; - } - if (this._clearFilterTriggered) { this.callback(event, { columnDef: this.columnDef, clearFilterTriggered: this._clearFilterTriggered, shouldTriggerQuery: this._shouldTriggerQuery }); this.$filterElm.removeClass('filled'); } else { + const eventType = event?.type ?? ''; let value = event?.target?.value ?? ''; const enableWhiteSpaceTrim = this.gridOptions.enableFilterTrimWhiteSpace || this.columnFilter.enableTrimWhiteSpace; if (typeof value === 'string' && enableWhiteSpaceTrim) { @@ -186,7 +186,7 @@ export class InputFilter implements Filter { } value === '' ? this.$filterElm.removeClass('filled') : this.$filterElm.addClass('filled'); const callbackArgs = { columnDef: this.columnDef, operator: this.operator, searchTerms: [value], shouldTriggerQuery: this._shouldTriggerQuery }; - const typingDelay = (event?.key === 'Enter' || event?.type === 'blur') ? 0 : this._debounceTypingDelay; + const typingDelay = (eventType === 'keyup' && event?.key !== 'Enter') ? this._debounceTypingDelay : 0; if (typingDelay > 0) { clearTimeout(this._timer as NodeJS.Timeout); diff --git a/packages/common/src/interfaces/gridOption.interface.ts b/packages/common/src/interfaces/gridOption.interface.ts index bc418a3de..c385be2c4 100644 --- a/packages/common/src/interfaces/gridOption.interface.ts +++ b/packages/common/src/interfaces/gridOption.interface.ts @@ -343,7 +343,9 @@ export interface GridOption { exportOptions?: TextExportOption; /** - * Default to 0ms, how long to wait between each characters that the user types before processing the filtering process (only applies for local/in-memory grid). + * Default to 0, how long to wait between each characters that the user types before processing the filtering process (only applies for local/in-memory grid). + * Especially useful when you have a big dataset and you want to limit the amount of search called (by default every keystroke will trigger a search on the dataset and that is sometime slow). + * This is only used by and relevant to 2 filters (InputFilter & CompoundInputFilter) which are the only ones triggering a search after each character typed. * NOTE: please note that the BackendServiceApi has its own `filterTypingDebounce` within the `BackendServiceApi` options which is set to 500ms. */ filterTypingDebounce?: number; diff --git a/packages/common/src/services/filter.service.ts b/packages/common/src/services/filter.service.ts index 536304dd1..11511e742 100644 --- a/packages/common/src/services/filter.service.ts +++ b/packages/common/src/services/filter.service.ts @@ -642,7 +642,7 @@ export class FilterService { * @param grid */ populateColumnFilterSearchTermPresets(filters: CurrentFilter[]) { - if (Array.isArray(filters) && filters.length > 0) { + if (Array.isArray(filters)) { this._columnDefinitions.forEach((columnDef: Column) => { // clear any columnDef searchTerms before applying Presets if (columnDef.filter && columnDef.filter.searchTerms) { diff --git a/packages/common/src/services/sort.service.ts b/packages/common/src/services/sort.service.ts index c9341dced..7ff8530a3 100644 --- a/packages/common/src/services/sort.service.ts +++ b/packages/common/src/services/sort.service.ts @@ -294,10 +294,8 @@ export class SortService { } }); - if (sortCols.length > 0) { - this.onLocalSortChanged(this._grid, sortCols); - this._grid.setSortColumns(sortCols.map(s => ({ columnId: s.columnId, sortAsc: s.sortAsc }))); // use this to add sort icon(s) in UI - } + this.onLocalSortChanged(this._grid, sortCols); + this._grid.setSortColumns(sortCols.map(col => ({ columnId: col.columnId, sortAsc: col.sortAsc }))); // use this to add sort icon(s) in UI } return sortCols; diff --git a/packages/vanilla-bundle/dist-grid-bundle-zip/slickgrid-vanilla-bundle.zip b/packages/vanilla-bundle/dist-grid-bundle-zip/slickgrid-vanilla-bundle.zip index 1cc89d514..6c570bb64 100644 Binary files a/packages/vanilla-bundle/dist-grid-bundle-zip/slickgrid-vanilla-bundle.zip and b/packages/vanilla-bundle/dist-grid-bundle-zip/slickgrid-vanilla-bundle.zip differ diff --git a/packages/vanilla-bundle/src/components/__tests__/slick-vanilla-grid.spec.ts b/packages/vanilla-bundle/src/components/__tests__/slick-vanilla-grid.spec.ts index cb9d7b7b2..3fc2fb961 100644 --- a/packages/vanilla-bundle/src/components/__tests__/slick-vanilla-grid.spec.ts +++ b/packages/vanilla-bundle/src/components/__tests__/slick-vanilla-grid.spec.ts @@ -13,6 +13,7 @@ import { ExtensionUtility, Filters, FilterService, + Formatter, GridEventService, GridOption, GridService, @@ -20,8 +21,9 @@ import { GridStateService, GridStateType, GroupingAndColspanService, + OnRowCountChangedEventArgs, OnRowsChangedEventArgs, - OnRowsOrCountChangedEventArgs, + OnSetItemsCalledEventArgs, Pagination, PaginationService, ServicePagination, @@ -35,8 +37,6 @@ import { TreeDataService, TranslaterService, SlickEditorLock, - Formatter, - OnSetItemsCalledEventArgs, } from '@slickgrid-universal/common'; import { GraphqlService, GraphqlPaginatedResult, GraphqlServiceApi, GraphqlServiceOption } from '@slickgrid-universal/graphql'; import { SlickCompositeEditorComponent } from '@slickgrid-universal/composite-editor-component'; @@ -200,7 +200,7 @@ const mockDataView = { mapIdsToRows: jest.fn(), mapRowsToIds: jest.fn(), onRowsChanged: new MockSlickEvent(), - onRowsOrCountChanged: new MockSlickEvent(), + onRowCountChanged: new MockSlickEvent(), onSetItemsCalled: new MockSlickEvent(), reSort: jest.fn(), setItems: jest.fn(), @@ -1589,7 +1589,7 @@ describe('Slick-Vanilla-Grid-Bundle Component instantiated via Constructor', () const emptySpy = jest.spyOn(component.slickEmptyWarning, 'showEmptyDataMessage'); component.columnDefinitions = mockColDefs; component.refreshGridData([]); - mockDataView.onRowsOrCountChanged.notify({ currentRowCount: 0, dataView: mockDataView, itemCount: 0, previousRowCount: 0, rowCountChanged: false, rowsChanged: false, rowsDiff: [0] }); + mockDataView.onRowCountChanged.notify({ current: 0, previous: 0, dataView: mockDataView, itemCount: 0, callingOnRowsChanged: false }); setTimeout(() => { expect(component.columnDefinitions).toEqual(mockColDefs); @@ -1687,7 +1687,7 @@ describe('Slick-Vanilla-Grid-Bundle Component instantiated via Constructor', () }); }); - it('should have custom footer with metrics when the DataView "onRowsOrCountChanged" event is triggered', () => { + it('should have custom footer with metrics when the DataView "onRowCountChanged" event is triggered', () => { const mockData = [{ firstName: 'John', lastName: 'Doe' }, { firstName: 'Jane', lastName: 'Smith' }]; const invalidateSpy = jest.spyOn(mockGrid, 'invalidate'); const expectation = { @@ -1701,7 +1701,7 @@ describe('Slick-Vanilla-Grid-Bundle Component instantiated via Constructor', () component.gridOptions = { enablePagination: false, showCustomFooter: true }; component.initialization(divContainer, slickEventHandler); const footerSpy = jest.spyOn(component.slickFooter, 'metrics', 'set'); - mockDataView.onRowsOrCountChanged.notify({ currentRowCount: 2, dataView: mockDataView, itemCount: 2, previousRowCount: 1, rowCountChanged: false, rowsChanged: false, rowsDiff: [2] }); + mockDataView.onRowCountChanged.notify({ current: 2, previous: 0, dataView: mockDataView, itemCount: 0, callingOnRowsChanged: false }); expect(invalidateSpy).toHaveBeenCalled(); expect(component.metrics).toEqual(expectation); diff --git a/packages/vanilla-bundle/src/components/slick-vanilla-grid-bundle.ts b/packages/vanilla-bundle/src/components/slick-vanilla-grid-bundle.ts index 8134bffd9..4bf25cd3f 100644 --- a/packages/vanilla-bundle/src/components/slick-vanilla-grid-bundle.ts +++ b/packages/vanilla-bundle/src/components/slick-vanilla-grid-bundle.ts @@ -862,10 +862,10 @@ export class SlickVanillaGridBundle { } // When data changes in the DataView, we need to refresh the metrics and/or display a warning if the dataset is empty - const onRowsOrCountChangedHandler = dataView.onRowsOrCountChanged; - (this._eventHandler as SlickEventHandler>).subscribe(onRowsOrCountChangedHandler, (_e, args) => { + const onRowCountChangedHandler = dataView.onRowCountChanged; + (this._eventHandler as SlickEventHandler>).subscribe(onRowCountChangedHandler, (_e, args) => { grid.invalidate(); - this.handleOnItemCountChanged(args.currentRowCount || 0, this.dataView.getItemCount()); + this.handleOnItemCountChanged(args.current || 0, this.dataView.getItemCount()); }); const onSetItemsCalledHandler = dataView.onSetItemsCalled; (this._eventHandler as SlickEventHandler>).subscribe(onSetItemsCalledHandler, (_e, args) => { @@ -878,7 +878,7 @@ export class SlickVanillaGridBundle { const onRowsChangedHandler = dataView.onRowsChanged; (this._eventHandler as SlickEventHandler>).subscribe(onRowsChangedHandler, (_e, args) => { if (args?.rows && Array.isArray(args.rows)) { - args.rows.forEach((row) => grid.updateRow(row)); + args.rows.forEach((row: number) => grid.updateRow(row)); grid.render(); } }); @@ -983,7 +983,7 @@ export class SlickVanillaGridBundle { executeAfterDataviewCreated(gridOptions: GridOption) { // if user entered some Sort "presets", we need to reflect them all in the DOM if (gridOptions.enableSorting) { - if (gridOptions.presets && Array.isArray(gridOptions.presets.sorters) && gridOptions.presets.sorters.length > 0) { + if (gridOptions.presets && Array.isArray(gridOptions.presets.sorters)) { this.sortService.loadGridSorters(gridOptions.presets.sorters); } } @@ -1219,7 +1219,7 @@ export class SlickVanillaGridBundle { private loadPresetsWhenDatasetInitialized() { if (this.gridOptions && !this.customDataView) { // if user entered some Filter "presets", we need to reflect them all in the DOM - if (this.gridOptions.presets && Array.isArray(this.gridOptions.presets.filters) && this.gridOptions.presets.filters.length > 0) { + if (this.gridOptions.presets && Array.isArray(this.gridOptions.presets.filters)) { this.filterService.populateColumnFilterSearchTermPresets(this.gridOptions.presets.filters); }