Sliding Window Pagination + Local Filtering: Preventing Page Reset and Avoiding Extra Backend Queries #2169
-
|
Hi all, I'm using Slickgrid-Universal . Here's my current setup: On first load, a query fires with payload: When navigating beyond 200 records, it fetches 100–300 records and adds them to the cache. I want to apply text filtering on a column without firing a backend query for every keystroke. Here's the behavior I'm seeing: With useLocalFiltering: true: I type, e.g., 'g' in a column filter while on page 6. The page number resets to 1, but the dataset displayed corresponds to the filtered page 6. The grid is visually inconsistent because pagination shows page 1 but rows reflect page 6 filtered data. With useLocalFiltering: false: What I want: Prevent firing a backend query on every filter change. Apply filters directly to the cached data. Keep pagination consistent, i.e., page number should reflect the currently displayed filtered page. Avoid the UI showing page 1 while displaying filtered results from a different page. I'm already caching blocks of data using fetchAndCacheWindow(startRow, sortModel) with a window size of 200. I’m updating dataset after applying the filter to blockCacheRef.current. The challenge is to synchronize SlickGrid’s pagination component with the filtered dataset so that it doesn’t reset page numbers or misrepresent filtered rows. Is there a recommended pattern for filtering in a sliding window cache while keeping pagination consistent? How can I apply filters locally without triggering backend queries, yet allow SlickGrid to correctly render pagination and page numbers? Any suggestions for hooking into SlickGrid events like onFilterChanged to achieve this behavior cleanly? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
|
never heard of "sliding window pagination". The reason that I added |
Beta Was this translation helpful? Give feedback.
-
|
If we’re implementing custom sliding-window pagination, how do we stop SlickGrid from resetting the page number (e.g., when filters are applied)? Is return false in onFilterChanged the correct way, or is there a cleaner option? currentPageRef=useRef(); gridOptions={ const sub1 = grid.eventPubSubService?.subscribe('onPaginationChanged', (data) => { const skip = (currentPageRef.current - 1) * pageSize; const gridInstance = reactGridRef.current?.slickGrid; const sub2 = grid.eventPubSubService?.subscribe('onFilterChanged', (data) => { |
Beta Was this translation helpful? Give feedback.
Sorry but I already said that I won't support this and I have no intention on spending time on this either, your use case is not the typical use case... nonetheless, you should look at Example 42 with a Custom Pager, but that probably won't be enough and you might need to directly
extendsthe built-in Pagination with TypeScript (not with React but with just native TypeScript) and modify it to your needs. Everything in the project is extendable with TypeScript to make it easier and doable to modify to your needsslickgrid-universal/packages/pagination-component/src/slick-pagination.component.ts
Lines 15 to 20 in 48b37a2