Uh oh!
There was an error while loading. Please reload this page.
fix(grid): ObjectGrid 真正的服务端分页 (#2212) - #1913
Merged
Merged
Conversation
Pairs with the framework findData fix (objectstack-ai/objectstack#2212). Once the backend reports the real match `total`/`hasMore`, the grid must actually USE it: fetch one page at a time with $skip and refetch on navigation, rather than fetching a single batch and slicing it in memory (which left records beyond the first batch unreachable). - ObjectGrid: add serverPage/serverPageSize state; fetch with $top + $skip = (page-1)*size; reset to page 1 when object/filter/sort changes. For the flat server-fetched list (not inline data, not grouped), drive DataTable in manual mode with rowCount = real total and onPageChange/onPageSizeChange refetching from the server. - DataTable: add manualPagination/rowCount/page/onPageChange/onPageSizeChange. In manual mode it renders `data` as the current page WITHOUT client slicing and derives total pages from rowCount. - data-objectstack adapter: prefer the server's `hasMore`, falling back to the page-local estimate only when absent. - types: declare the new DataTable manual-pagination props. Tests: new data-table-manual-pagination.test.tsx (3) and ObjectGrid serverPagination.test.tsx (4, renders the real ObjectGrid against a mock server and asserts $skip refetch + true page count). Full suite green (4227 passed | 24 skipped).
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
✅ Console Performance Budget
📦 Bundle Size Report
Size Limits
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
配合框架修复 objectstack-ai/objectstack#2212(
findData返回真实total/hasMore)。后端报对了匹配总数与
hasMore之后,前端还必须真正用上它:按页用$skip取数、翻页时重新请求,而不是一次取一批后在内存里切片——后者会让第一批之后的记录永远翻不到。改动
packages/plugin-grid/src/ObjectGrid.tsx):新增serverPage/serverPageSize状态;以$top+$skip = (page-1)*size取数;对象/筛选/排序变化时重置到第 1 页。对扁平的服务端列表(非内联数据、非分组视图),以 manual 模式驱动 DataTable:rowCount= 真实总数,onPageChange/onPageSizeChange触发服务端重新取数。packages/components/src/renderers/complex/data-table.tsx):新增manualPagination/rowCount/page/onPageChange/onPageSizeChange。manual 模式下把data当作当前页原样渲染、不做客户端切片,并按rowCount计算总页数。packages/data-objectstack/src/index.ts):优先采用服务端hasMore,缺失时才退化为页内估计。packages/types/src/data-display.ts):声明 DataTable 的 manual 分页属性。测试
data-table-manual-pagination.test.tsx(3 例):按rowCount推总页数、不做客户端切片、onPageChange上报翻页。plugin-grid/.../serverPagination.test.tsx(4 例):渲染真实 ObjectGrid + mock 服务端,断言首页$skip=0、翻页$skip>0重新取数、总页数取自真实 total、改页大小重新取数并回到第 1 页。