fix(grid): sort paginated table data server side

This commit is contained in:
jearhe authored and GitHub committed 2026-08-31 23:45:40 +08:00
1 parent f075caef21
commit 40a806a24a
5 files changed
+251 -6

No files matched your search

@@ -3818,7 +3818,8 @@ function currentWhereInput(): string | undefined {
}
function currentOrderBy(): string | undefined {
return orderByInput.value.trim() || (sortCol.value ? `${queryColumnRef(sortCol.value)} ${sortDir.value.toUpperCase()}` : undefined);
const structuredOrderBy = sortMode.value === "database" && sortCol.value ? `${queryColumnRef(sortCol.value)} ${sortDir.value.toUpperCase()}` : undefined;
return orderByInput.value.trim() || structuredOrderBy;
}
function executeServerPageJump(targetPage: number, updateCurrentPage = false) {
@@ -32,4 +32,11 @@ describe("DataGrid infinite-scroll sorting", () => {
expect(sortSource).toContain("} else {\n currentPage.value = 1;\n resetGridVerticalScroll(true);\n }");
expect(sortSource.match(/emit\("sort"/g)).toHaveLength(1);
});
it("does not expose an explicit local sort as a database order for refresh or pagination", () => {
const orderSource = functionSource("currentOrderBy", "executeServerPageJump");
expect(orderSource).toContain('sortMode.value === "database"');
expect(orderSource).toContain("return orderByInput.value.trim() || structuredOrderBy;");
});
});