Docs
Recipes

Stock editor

Validate cell edits and recalculate stock totals.

What you will build

Edit stock directly, reject invalid quantities and keep totals consistent after a write.

Start with the React setup or Vue setup. Use the complete files below with the shared recipe modules. The browser-memory store resets on reload; an API integration must preserve the same contracts.

Required files: shared/products.ts, shared/store.ts, product-config.ts, list-records.ts, view-actions.ts, editable-actions.ts, product-form.ts, get-form-config.ts, stock-config.ts, recipe-stock.

Copy the shared mutation store and adapter, plus the product form catalog. The stock column uses that field schema and the same update action as a full form.

stock-config.ts

stock-config.ts
import { defineTableConfig } from "@/components/ui/yayaw-table/config/helpers";
import { productConfig } from "./product-config";

export const stockConfig = defineTableConfig({
  ...productConfig,
  columns: {
    ...productConfig.columns,
    definitions: productConfig.columns.definitions.map((column) =>
      column.id === "stock"
        ? {
            ...column,
            inlineEdit: { enabled: true, editor: "number" },
            defaultCalculation: "sum",
          }
        : column
    ),
  },
  table: {
    ...productConfig.table,
    allowInlineEdit: true,
    allowEdit: true,
    enableCalculations: true,
    inlineEdit: { enabled: true, debounceMs: 400, optimistic: true },
    rowClickMode: "none",
  },
});
stock-config.ts
import { defineTableConfig } from "@/components/ui/yayaw-table-vue/config";
import { productConfig } from "./product-config";

export const stockConfig = defineTableConfig({
  ...productConfig,
  columns: {
    ...productConfig.columns,
    definitions: productConfig.columns.definitions.map((column) =>
      column.id === "stock"
        ? {
            ...column,
            inlineEdit: { enabled: true, editor: "number" },
            defaultCalculation: "sum",
          }
        : column
    ),
  },
  table: {
    ...productConfig.table,
    allowInlineEdit: true,
    allowEdit: true,
    enableCalculations: true,
    inlineEdit: { enabled: true, debounceMs: 400, optimistic: true },
    rowClickMode: "none",
  },
});

Entry component

Expand ↗

Sample data. Changes stay in this preview.

Expand ↗

Sample data. Changes stay in this preview.

Verify the result

  1. The initial stock total is 18.

  2. Edit Oak desk stock from 12 to 15 and commit: the total becomes 21.

  3. Try -1 or 1.5: validation refuses the value.

  4. Filter Status to Draft: the stock total is zero.

  5. Clear filters and confirm the successful edit is still present.

Use the existing playground to explore the library’s controls.

The React recipe invalidates the footer calculation cache after a successful update. In the verified registry, this cache uses ["tableColumnCalculations", tableId] separately from row data. Keep that refresh when adapting the recipe to a server action; a failed validation leaves the existing total unchanged.

Walk through the result

ActionExpected result
Open the stock table.Stock totals 18: 12 + 0 + 6.
Replace Oak desk stock with 15.The record is saved and the total becomes 21.
Try -1 or 1.5.Validation rejects the write and the last saved value stays intact.
Set Desk lamp stock to 0.Zero remains a valid number; it is not treated as an empty field.

On mobile, use View settings for presentation, the Data menu for export, and the search button in the toolbar. Resetting a view does not undo writes. Try the keyboard as well as pointer input.