Query forms and request proxy guide

Table query forms and request proxy behavior, configuration, and runnable examples.

Query forms and request proxy guide

Query forms and request proxy

Query forms, toolbars, and request proxies are enabled through STable configuration. The examples progress from query interactions to generated data, remote requests, save, and delete.

Query and toolbar

Continue using s-table when a table needs a query area, toolbar or request proxy. Enable or combine query-config, toolbar-config and proxy-config independently; when none is supplied, no business configuration area is rendered. The examples below cover manual queries, slots with nested columns, generated data, remote requests, and save and delete operations.

s-table accepts Table props, events and slots, sharing its pagination, sorting, filtering and selection behavior. Add a Form with query-config and business actions with toolbar-config.

Provide a reactive queryConfig.model; field changes and reset follow the SForm model contract. There is no separate query defaultValue: when a field first mounts, Form deep-clones its value from model as the reset baseline. Configure items, rules, labelPosition and other form options as usual.

labelPosition defaults to right, which keeps the label beside the control with right-aligned text; left keeps the same side-by-side layout with left-aligned text, and only an explicit top places the label above the control. Configured renderers and form items appended through slots follow the same rule. Use built-in renderer names such as $input and $select in itemRender.

Search or native form submission validates fields, requests page one, then emits query. Reset restores the initial snapshot and requests page one. Refresh keeps the current page and conditions without validating fields.

queryConfig.fixedButtons is the ordered fixed-action region and defaults to ['submit', 'reset']. Add more to reveal or collapse query items whose visible value is false. Pass [] to remove all built-in buttons and let the query-actions slot own the region.

The action region preserves its complete width at the right while fields share and wrap within the remaining track; in a narrow container it moves to the next line and stays right-aligned. Set a reusable default through SConfigProvider at table.queryConfig.fixedButtons; a local array, including an empty array, replaces it.

Size follows one predictable chain: SConfigProvider.size or SConfigProvider.table.size, then s-table size, then queryConfig.size or toolbarConfig.size, and finally an individual control or renderer props.size. Every renderer method receives the inherited value as params.size; its options.props.size is the effective component override. Built-in query actions, refresh, find and column settings follow the same chain.

The query event provides a { reason, form, pager, sortBy, filters } snapshot; reason is submit, reset or refresh. This example filters local data in the handler. Table does not automatically map form fields into table filters or send network requests. For remote data, handle the event and update data, loading and the pagination total yourself.

Explicit pagerConfig.currentPage and pageSize fields are controlled; accept updates with v-model:pager-config. Query methods return false when page-one acceptance is rejected, validation fails, conditions change during asynchronous validation, the grid is loading, or the component is unmounted. Without a proxy, true only means the event was emitted. With a proxy, it means the query response was accepted.

Configure toolbarConfig.left and toolbarConfig.right as ordered global renderer lists using itemRender. The built-in button emits its own or a child action’s code through toolbarClick; child actions open through SPopper.

$refresh calls the current query or proxy refresh, $columnConfig opens column settings, and $find supplies an icon trigger that opens this Table’s find-and-replace panel in SPopper. Pass content or props.content to append a label after the icon. A custom renderer can implement renderToolbar(options, params), where params.source contains the Table API, query context, side, inherited size and busy state.

Toolbar renderers

toolbarConfig.left and toolbarConfig.right are ordered lists of itemRender entries. Table calls the selected registry entry’s renderToolbar with its side, inherited size, busy state, Table methods, and query context. The built-in button below emits a code through toolbarClick; $columnConfig opens the column settings panel. Try adding a row and changing column visibility.

Query item renderers

queryConfig.items[].itemRender uses the same configuration and renderFormItem method as Form schema items. The query model, field value, and setValue come from that Form instance. See Form’s custom renderer example for the callback contract; Table adds query orchestration after Form validates. The query and toolbar example above uses $input and $select in its items.

Slots and nested columns

Map a query item’s default, label, or error entry in queryConfig.items[].slots directly to an identically named application slot. Names are used as written; Table does not add a query- prefix. Replace query buttons through query-actions and set fixedButtons: [] for a fully custom region. In addition to the Table API and busy, the slot receives expanded, hasMore, and toggleMore(). Replace the two toolbar regions through toolbar_left and toolbar_right, and its title through toolbar-title. The query slot can add s-form-item controls to the same form.

Other slots pass through to Table, including header, footer, cells, editors and default s-table-column declarations. This example combines nested columns, tree expansion, fixed columns and virtual scrolling. Applying conditions displays the submitted keyword while preserving the tree data.

query, query-actions, toolbar_left, toolbar_right, toolbar-title, and proxy-error are fixed Table slots. Query items and configured columns should explicitly map application-owned unique names; multiple configurations may deliberately reuse the same business slot. Conditional slots can be added or removed after mounting; removing one restores the corresponding fallback.

Generated data

Call Table methods such as scrollToRow, scrollToColumn, editing, validation and data mutations. virtualSource and virtualConfig retain their Table contracts.

This example supplies one million rows and one hundred thousand columns on demand, reading only rendered fields. Query snapshots contain conditions without copying row or column data. The buttons navigate to the first and last records. The application still owns ordinary arrays and any remote loading or persistence for generated data.

Request proxy

Provide proxy-config.query to receive { action, reason, form, pager, sortBy, filters, signal } and return { data, total }. Pagination requires a non-negative integer total, counting root records for trees. The proxy enables remote pagination, sorting and filtering so a returned page is not sliced or sorted again locally.

This example uses computed<SaxGridSetting<ProjectRow, ProjectQueryForm>>(). The query adapter therefore receives ProjectQueryForm in form, must return ProjectRow[], and keeps the same types in toolbar slots, events, and TableExposes<ProjectRow, ProjectQueryForm> methods.

Queries run after mounting unless autoLoad: false. Accepted page, page-size, sort and filter changes trigger a query unless autoQuery: false; sort and filter changes request page one. Typing in the form does not trigger requests by itself. query() validates the form and requests page one; resetQuery() resets the form and requests page one; refresh() keeps the current page. commitProxy('query') and commitProxy('refresh') dispatch the current conditions directly, without additional form validation or page reset.

Without data, Table stores accepted responses. When data is supplied, the parent must accept the proposed array through v-model:data or update:data; otherwise the operation returns rejected. Failed requests retain previous data. Disable the proxy to keep managing requests through the existing query event yourself.

A newer query cancels the previous one, and late responses cannot overwrite current data. Explicit cancellation, disabling the proxy, replacing adapters, changing dataKey and unmounting abort pending requests. Pass signal to clients such as fetch and check it before delayed writes. Client cancellation does not guarantee rollback of a server write.

This example simulates a service with delays and supports pagination, sorting, team filters, retry and cancellation, together with fixed columns, dynamic heights and virtualization. Query adapters return a bounded array page. Generated virtualSource loading remains application-owned; direct proxy queries return unsupported for that mode.

Save and delete

Enable change-config and call commitProxy('save') to pass existing change records to proxyConfig.save. Apply drafts with Table’s commitEdit() before persisting; an active draft returns editing. Inserted and updated rows are validated before saving; invalid data returns invalid, and no changes returns empty.

The save adapter receives inserted, updated and removed records with a version. Successful saves only accept the same data baseline and version. If external data or the record version changes while waiting, the operation returns stale and preserves current data. Row references are read-only and changed field values are snapshots; the application decides which fields to serialize.

validationColumns can limit save validation. Generated sources require explicit numeric validationColumns and changeConfig.indexOf so only affected rows and specified columns are accessed; disable automatic reload and refresh the generated source in your adapter.

commitProxy('delete', rows) passes explicit rows to the delete adapter. Omit rows to use Table’s current selection; an empty array returns empty. Queries and deletes return dirty when unsaved changes exist. Save first or call revertChanges(). The adapter owns server deletion; Table does not silently remove local rows.

Writes are mutually exclusive and other proxy operations return busy while a write is pending. Returning false rejects a write; exceptions emit proxyError. Both preserve data and change records. Successful writes reload by default; disable this with reloadAfterMutation: false. A successful write stays success if its reload fails: inspect result.reload instead of submitting the successful write again.

getProxyState() and proxyStateChange provide loading, action, error and the latest result. Cancellation returns cancelled. This example uses simulated service data to demonstrate applying drafts, saving, inserting, deleting and reverting changes.

Last Updated: 2026-10-28, 06:17:56 UTC
Copied