Admin data views, filters, and pagination
Manage applied filters, query keys, server-side sorting, and refresh after writes.
The feature page owns list state. AppDataView combines filters, toolbar controls, the table, and pagination. The feature queries using applied filters and refreshes affected data after writes. Service owns authorization, validation, and persistence.
When a filter changes the query
On the member list at /member/accounts, editing a filter updates a draft. Submitting applies filters, returns to page one, and clears selection. The query key includes keyword, status, page, and page size, so different scopes have separate cached results.
| Desired behavior | Use |
|---|---|
| Share a filtered URL | The default filters query parameter, with applied, serializable values that differ from defaults |
| Drive the query directly from the URL | useAppDataFilterQuery, passed to filterForm.query |
| Picker dialog or temporary filters | filterForm.urlQuery: false, also used by the member list |
| Keep a local or sensitive field on the page | Set its queryValue: false. Password controls stay local by default |
URL filters are JSON encoded through URLSearchParams. Invalid JSON, unexpected types, and retired options fall back to defaults. Choose separate parameter keys when two lists share a route.
Paginate and sort server-side lists
Offset pages start at 1. Correct out-of-range pages after receiving a changed total. Cursor lists use cursorPagination and follow nextCursor. The feature stores earlier cursors for going back. When filters, sort, or page size change, restart at the first page or initial cursor. Use manualSorting for server-side sort and map column IDs and directions to API fields. Use stable row IDs so selection stays attached to the intended rows during refresh.
Why a saved edit can leave stale rows
Check the write response and the query cache separately. After a successful write, update or invalidate affected lists, details, and pickers. For a tree, include the affected parent branch. The member list invalidates ["member"] queries after a batch status write. The standard batch run stops at the first failure and reports successes and failures to onSettled, so the page can refresh and report the partial result.
Start in apps/admin/src/common/data/data-view.tsx, data-filter-search.ts, and the owning feature page. For drafts and field errors, see Admin forms.