跪拜 Guibai
← All articles
Frontend

Single Source of Truth: VTable Guild 3.0.0 Derives Query, Edit, and Display from One Column Config

By parade岁月 ·
Read original on juejin.cn ↗ Google Translate ↗ Alt translation

Admin-heavy Vue 3 projects can now define a table's display, query, and editing behavior in one declarative place, cutting boilerplate and preventing the drift between form options and column labels. The 3.0.0 upgrade is not drop-in: `clearFilters()` semantics and `rowSelection` ordering change, so teams on 2.8.1 must review those before adopting.

Summary

VTable Guild 3.0.0 for Vue 3 consolidates the repetitive wiring between tables, query forms, and edit controls into a single `columns` definition. A `valueEnum` map defined once on a column drives the table cell's display (as a tag or text), the dropdown options in the query form, and the select control in the inline editor. The new `VTableQuery` component and `useTableQuery` hook turn that column config into a working filter bar, with support for a compact LightFilter layout where conditions appear as clickable tags.

Inline editing moves from per-cell glue to a draft-aware workflow. `useTableEditable` plugs into `bodyCell`, manages row drafts, cancellation, and validation, and supports batch submission where an invalid row is located and scrolled into view. The same editor controls are shared with the query layer via an adapter factory for Ant Design Vue or Element Plus. Display formatting is unified with built-in renderers for tags, amounts, dates, and percentages, and custom renderers can be defined and reused.

The release also brings request management (`useTableRequest`) that guards against stale responses and page-number overflows, column state persistence (`useColumnState`), and lazy loading for tree data. VTable Guild remains a focused table component, not a full admin framework: page flow, permissions, and transactions stay in the application's hands. Upgrading from 2.8.1 comes with three notable behavior changes, including a new default for `clearFilters()` and alignment of `selectedRows` ordering.

Takeaways
— `valueEnum` defined once on a column drives the table display, the query dropdown, and the inline editor options.
— `VTableQuery` and `useTableQuery` build a filter bar from column config, with `search: false` to exclude fields and a LightFilter layout for tag-style conditions.
— `useTableEditable` manages row drafts, cancellation, and validation; batch submit can validate and scroll to an invalid row, and preserve drafts on API failure.
— Built-in renderers handle tags, amounts, dates, and percentages; custom renderers via `createTableRenderers` can be reused across tables.
— `useTableRequest` prevents stale responses from overwriting new results and handles page-number overflow after deleting the last remote row.
— `useColumnState` persists column visibility, order, and fixed state across sessions.
— Tree data supports lazy loading of children with loading, error, and retry states.
— Same table logic works with Ant Design Vue or Element Plus via adapter factory and theme presets.
— In 3.0.0, `clearFilters()` now commits reset filters and closes the panel; use `clearFilters({ confirm: false, closeDropdown: false })` to only reset drafts.
— `rowSelection.onChange` now returns `selectedRows` in `selectedRowKeys` order, skipping keys without records.
Conclusions

Defining query and editor options from the same `valueEnum` enforces consistency at the schema level, so a developer can't accidentally introduce a mismatch between what the table shows and what the filter offers.

By keeping the component's scope to the table itself and leaving page flow and permissions to the application, the project avoids the feature creep that plagues many admin frameworks.

The support for both Ant Design Vue and Element Plus via an adapter factory suggests the table logic is framework-agnostic, but the styling and control specifics still require per-library adapters, which adds a maintenance surface.

Concepts & terms
valueEnum
A mapping in a column definition that associates raw values with display labels. In VTable Guild, a single valueEnum can drive the cell renderer, the query dropdown options, and the inline editor options simultaneously.
LightFilter
A compact filter layout where common conditions are displayed as clickable tags rather than in a full form. Clicking a tag opens a popup to set the value, saving vertical space in dense admin pages.
Source: juejin.cn ↗ Google Translate ↗ Backup ↗