Server-Side Data (PageCacheDataSource)
Overview
PageCacheDataSource loads data from a remote server in pages, caching them
in memory with LRU eviction. Cells that haven't been fetched yet render as
skeleton loading placeholders.
Creating a page cache
Page lifecycle
- Detect needed pages — call
cache.needed_pages(first_row, last_row)to find pages in the visible range that are neither loaded nor pending - Mark as pending —
cache.mark_pending(page_num)prevents duplicate fetches - Fetch data — your application fetches the data from the server
- Insert the page —
cache.insert_page(page_num, rows)stores the data - Notify the grid —
state.apply(GridCommand::NotifyPageLoaded)triggers re-render
FetchConfig (automatic fetching)
rs-grid-web provides a built-in fetch coordinator via FetchConfig:
PageFetchRequest
The fetcher automatically:
- Checks which pages are needed for the current viewport
- Prefetches
buffer_pagespages ahead and behind - Spawns async
window.fetch()calls - Parses JSON responses via your
parse_responseclosure - Updates the cache and triggers
NotifyPageLoaded
API reference
CellStatus
PageCacheDataSource returns meaningful CellStatus values:
The renderer draws a skeleton animation for Loading cells.
LRU eviction
When the cache exceeds max_cached_pages, the least-recently-accessed
pages are evicted. Re-accessing a page moves it to the back of the
eviction queue.
Invalidation on sort/filter change
When sort or filter changes in server-side mode, call cache.clear() to
invalidate all pages, then let the fetcher re-fetch with the new parameters.
Shared state
PageCacheDataSource uses Rc<RefCell<...>> internally — cloning it
creates a shared reference to the same cache. This is how the fetch
coordinator and the grid model share the same data.