Data Entry
FaifoGrid
An editable grid for entering many lines.
import { FaifoGridPlaceholder } from 'faifo-design'FaifoGrid is an editable grid drawn in the browser: arrow keys move, Enter, F2 or typing edits,
Tab goes to the next editable cell, and a block can be pasted from a spreadsheet. The server renders
only FaifoGridPlaceholder; the faifoGrid island draws the grid, and createFaifoGrid builds one
in a container an application owns.
#When to use
- Use it for the lines of a document: an order, a bill, a count.
- The grid posts its changes through one named field, so the form around it still saves once.
- For read-only rows use
DataTableorFaifoTable.
#Examples
Each example is a specimen of the package catalogue, rendered on the server exactly as shown in its code.
#Faifo grid
Editable grid drawn entirely in the browser: the server renders only its loading placeholder. Arrow keys move, Enter or F2 or typing edits, Tab moves to the next editable cell, Ctrl+C/V copies and pastes ranges with spreadsheets, Ctrl+D fills down, Ctrl+Z undoes, Alt+↑/↓ or the handle reorders. Cells the reader may edit are light green and an edited cell turns light yellow until the host saves; a row is filled whole only when every cell is (sections, notes, a new or moved row). The order lines show sections and notes, a delivered (read-only) line, a pinned subtotal and its total; the stock list draws 500 rows by drawing only those in view.
Show codeHide code
import { renderIsland, trustedMarkup } from '@ketvietlab/ketjs-view'
import { FaifoGridPlaceholder, Stack, faifoGrid } from 'faifo-design'
// faifoGridDemoConfig: a catalogue fixture, packages/faifo-design/src/interactions/faifo-grid/demo.ts
// faifoGridStockDemoConfig: a catalogue fixture, packages/faifo-design/src/interactions/faifo-grid/demo.ts
export const Example = () => (
<Stack
items={[
trustedMarkup(
renderIsland('design-system.faifo-grid', faifoGrid, {
id: 'demo-faifo-grid',
config: faifoGridDemoConfig,
}),
),
trustedMarkup(
renderIsland('design-system.faifo-grid', faifoGrid, {
id: 'demo-faifo-grid-stock',
config: faifoGridStockDemoConfig,
}),
),
<FaifoGridPlaceholder label="Loading order lines" rows={3} />,
]}
/>
)#Contract
#Editable grids: FaifoGrid
Serialized columns accept writeSets for constant dependent values after a successful
write, including a computed inverse. For example, a product/unit selection can set
automatic: true, while a price or margin edit sets it to false. Failed inverse
writes do not change intent. Declare boolean draftFlags: ['automatic'] to preserve
that user-owned intent after draft restoration replays column writers. Non-boolean,
undeclared and row/tier/column lock flags are excluded. Server validation remains
mandatory. The order-lines specimen demonstrates this contract.
Reading a collection is FaifoTable's job. Editing many rows in place (order lines, stock
counts, price lists, any table whose numbers change live) uses FaifoGrid, which runs entirely
in the browser. Do not put form controls in DataTable or FaifoTable cells, and do
not edit such figures through one dialog per row; a dialog stays for one record's own action
(a reason, a confirmation, adding a found item). A dialog setting a quantity per variant holds
such a grid too, one row per variant.
- Two entries.
createFaifoGrid(container, options)builds the grid from client code and returns its API (changes(),posted(),validate(),setRows(),applyTransaction(),setErrors(),markSaved(),undo(),destroy()and the rest ofFaifoGridApi).faifoGridis the same grid as a ketjs-view island: the server renders onlyFaifoGridPlaceholder, the island takes JSON config (columns, rows,newRow,kindField/fullWidthKeyfor section and note rows,lockedField,keptFieldfor a row that stays editable but may not be removed,compute,search.listFunction) and dispatchesfaifo:grid-readywithdetail.gridso page code can feed it and save. - In a server-rendered form. A KetSuite route puts the grid in a form field as its
controlthrougheditGridControl(ctx, url, req, id, config)(ketsuite/backend, jointbackend:edit.grid), withconfig.nameset to the field name: the grid keeps a hidden field of that name holding its posted changes and blocks the submit while a changed cell is wrong. The route reads the rows of a grid that started empty withpostedGridRows(form[name])(added rows in order, without the ones removed again; null for anything else) and passescarry: form[name]back when it refuses the form, so the reader's rows survive. Do not ask for pasted JSON in a textarea instead.faifoGridLocale(lang)(ketsuite/ui) supplies the grid's Vietnamese or English labels. A grid in a two-column form takes the full row (span: 'full'). Size the columns to fit the field column at desktop width; on a phone the grid scrolls sideways inside its own frame, and its empty message stays centred on the visible part. - Row totals. A numeric island column may declare
sumEquals: { fields, total, message }. It validates that the sum of the named row fields equals the total field (quantity tolerance 0.000001), displaying the localized message at the edited cell. Attach it to each participating editable column; the domain must validate the same rule on save. - Computed values and inverse input. A product
computecan subtract another product throughless, show(product - less) / product * 100throughas: 'percent', and solve into exactly one multiplicand usingsolve: {field, digits}.percentOffapplies before subtraction. Inverse input uses decimal rational arithmetic and rounds once, half away from zero. Invalid or non-unique targets, zero divisors, missing costs and unsafe minor-unit results keep the row unchanged. Text target columns retain decimal strings; derived values are never persisted as their own fields. Existing simple products and differences keep their behavior. - Remote option facts.
search.setsFrommaps result fields to row fields on selection. Facts are cached perlistInputFieldscontext and option ID, bounded to 1000 entries, and do not cross product/quantity contexts. Declareresetsfor dependent facts; a refused draft cannot recreate a trusted remote response. Server permissions own what the endpoint returns. Consumers must omit display facts from business writes and revalidate every persisted field server-side. - Kinds of new row.
newRows: [{label, row}](client:{label, create}) gives one add button per kind, such as a line, a section and a note; it replacesnewRow. A section or note row shows, edits and checks only itsfullWidthKeycell, so a section is never "missing" a product or quantity.fullWidthTag: {field, label}showslabelafter the text of a section or note whosefieldis set (an optional section reads "Kit · Optional"); the tag is generated content of the cell's value (data-tagonfg-cell-value), so editing the text leaves it in place, and the cell'saria-descriptionso assistive technology reads it too. - Rules from row data. Island columns take JSON-safe rules, so the server's own data
drives them:
lockedBy: 'field'makes the column read-only on rows where that field is set (a product already delivered),requires: 'field'keeps it read-only until that field is set (a line's unit waits for its product, and closes again when the product is cleared),minField: 'field'refuses a value under that field (belowMin, "At least {min}"),maxField: 'field'one over it (aboveMax, "At most {max}", such as a quantity above what is still due), andsets: {optionValue: {field: value}}lets a choice fill other cells of its row (a product's description, unit, price and tax). A select column'soptionsBy: {field, values: {fieldValue: [optionValue]}}offers each row only the options itsfieldallows (a product's own unit and packagings); a row whose valuevaluesdoes not name gets every option, typed or pasted values outside the row's options are refused (invalidOption), and every value still shows its label. Client columns takeoptionsFor(row). They guide the reader; the server still checks the same rules. - Compact remote labels.
search.labelFieldmay name a short code whiledescriptionFieldretains the full name in the picker.labelFallbackFieldsupplies the cell label when that code is missing; it does not change the option ID. - Dependent fields and remote options.
resets: [fields]clears dependent cells only when the parent changes, beforesetsfills defaults; a dependent cell protected by itslockedByfield is retained. A row with an explicitoptionsByentry searches only those local options, even when the column also declares remote search.search.listInputFields: {input: rowField}reads required RPC inputs from the current row at search time; missing parents return no options and send no request. The request uses the grid’s abort signal. Server eligibility and permission checks remain authoritative. - Steps from row data. The island config's
tiers: {key, by, lockedBy?, steps}writes fields in steps of another field, as a pricelist prices a product by quantity:steps[row[key]]is a list of{from, row}, and the step with the largestfromat mostrow[by]writes itsrow. It applies aftersetswhenever thekeyor thebycell is edited, so a price typed by hand stays until the product or the quantity changes; a row whoselockedByfield is set (already delivered or invoiced) keeps its fields. Withwith: 'field'(the unit a line is sold in) the steps ofsteps["<key>|<with>"]come first, then those of the key alone, and editing that cell steps the row too, so choosing a packaging writes its own price. The server works the steps out from its own rules.stepsFieldnames a row-owned array of{from, row}supplied by a remote picker; when present, even an empty array replaces static steps. Steps must have finite numeric thresholds and object values.lockedByalso accepts an array of fields: any held lock prevents repricing, separating manual intent from fulfilment history. Lock fields cannot be restored throughdraftFlags. Server writers recalculate authoritative prices and never trust posted step arrays. The Order lines specimen's glass-cup row demonstrates the row-owned threshold at quantity48. - Computed columns. An island column's
computeis{multiply: [fields], percentOff?}(a line amount) or{difference: [a, b]},a − b, empty while either is missing (a count against the quantity on hand). Withless: [fields]the product of those fields comes off the amount (a line's margin: quantity × price less discount, less quantity × cost), and withas: 'percent'the result is that margin's share of the amount, empty when the amount is 0. Computed cells follow edits live and are read-only, unlesssolve: {field, digits?}names one ofmultiply: the column is then editable where itseditable/lockedByallow, and a value typed sets that field, rounded todigitsplaces (default 6), to what makes the row compute to it (a margin typed sets the unit price that earns it). A value no row computes to (100 % on a cost, a row selling none, a price below zero, a cleared cell) leaves the row as it was. The edit is the solved field's: it is what the grid marks unsaved and posts. A client column gets the same withvalueandsettogether. - Keyboard and clipboard. Arrows move, Shift extends, Ctrl/⌘+arrow jumps to the edge, Home/End and PageUp/PageDown work as in spreadsheets. Enter, F2 or typing edits (an IME composes in the editor); Tab moves to the next editable cell. Ctrl/⌘+C, X and V exchange ranges with spreadsheets as tab-separated text, Ctrl/⌘+D fills down, Delete clears, Space toggles a checkbox, Alt+↑/↓ or the handle reorders, and Ctrl/⌘+Z and Shift+Ctrl/⌘+Z undo and redo by operation.
- Values. Text, number, money, percent, date, select, combobox and checkbox columns read what
people type in either decimal convention (
1.250,5,1,250.5; money also25k,1,2tr), show values in the grid's locale, and keep a rejected entry open with its message. - Cell fills. Fills go by cell. A cell the reader may edit is light green
(
--faifo-success-bg); a cell whose value is not saved yet is light yellow (--faifo-warning-bg); read-only, computed and locked cells keep the plain fill. A row is filled as a whole, its drag handle too, only when every cell is: green when all its cells are editable (a section or note row), yellow when the row is new or was moved. The yellow clears when the host saves (markSaved(), orsetRows()with the saved rows) and when an edit or undo brings the value back. State tints (selection, invalid, conflict) and the active outline draw over the fill. Consumers do not restyle cells or rows. - Saving. The host saves. A grid with
name(andformwhen outside it) keeps a hidden text input holdingposted()as JSON ({added, updated, removed, order}, only changed fields of updated rows;orderlists every row id, new rows by their grid id, when rows moved or a row was added before the end) for the record form, or page code postschanges()itself. The input's default value is the clean JSON, exported asFAIFO_GRID_NO_CHANGES, so record drafts and "unsaved changes" checks see grid edits like any field: a record draft seedingcarryfalls back toFAIFO_GRID_NO_CHANGES, never''. A read-only grid with no form to post to omitsname/form/carry; a named field in it would read as an open control. Pressing anywhere outside the grid commits an open editor, and so does submitting that form; if any cell is invalid the grid stops the submit, focuses the first such cell and announcesfixBeforeSaving. Both listen onwindowin the capture phase, so they run before a host's own submit handlers read the form.noValidateon the form orformNoValidateon the submitter skips the check. After a successful save callmarkSaved()(or reload the rows); field errors from the server go tosetErrors(). - Paged rows. A grid shows one page of a larger set when the host pages it. Pass the
previous value of its input as
carry(island: the JSON string; client:FaifoGridPosted):updatedentries for rows on this page come back as unsaved edits, the others ride along inposted()and the status readsotherPages("{count} changed on other pages"), so one save covers every page.posted()includes optionaloptionLabelsfor learned remote labels while dirty; carry this display-only metadata through a refused form and discard it before the business write. Labels never authorize a value. Added/removed rows and row order are also restored when the corresponding capabilities allow them; added row IDs stay stable. Only editable cells are restored. Draft restoration replays column writers in declaration order: put parent columns before dependent cells. This recomputessets/resetsand hidden lock metadata before restoring the dependent value; posted hidden metadata cannot unlock a cell. The same rule applies to new rows.setReadOnly(true)freezes edits and undo while the host saves, without dropping the draft.setRows(),markSaved()and reverting drop the carried edits. - Live data.
applyTransaction({add, update, remove})merges rows changed elsewhere. Untouched cells take the new value and flash; a cell the reader changed keeps their value and offers "Keep mine" or "Use new value". - Scale. Rows have one height and only those in view are drawn, so a grid holds thousands of rows; columns may be pinned to either edge and footers sum a column.
Specimen: catalogue data-operations#faifo-grid. Tests: test/design-system-faifo-grid.test.ts.
#API
Generated from the package source. A property without a description has none in the source yet.
#createFaifoGridFunction
function createFaifoGrid<Row extends FaifoGridRow = FaifoGridRow>(container: HTMLElement, options: FaifoGridOptions<Row>): FaifoGridApi<Row>| Parameter | Type |
|---|---|
containerrequired | HTMLElement |
optionsrequired | FaifoGridOptions<Row> |
| Returns | FaifoGridApi<Row> |
#FAIFO_GRID_NO_CHANGESConstant
What the grid's named field holds before any edit; a record draft that seeds it starts here too.
const FAIFO_GRID_NO_CHANGES = JSON.stringify({ added: [], updated: [], removed: [], order: null })#faifoGridFunction
The grid as a ketjs-view island: the server renders the placeholder, the browser the grid.
function faifoGrid(props: IslandProps): IslandController| Parameter | Type |
|---|---|
propsrequired | IslandProps |
| Returns | IslandController |
#FaifoGridPlaceholderComponent
The server's stand-in until the grid draws itself: a frame of loading lines.
| Property | Description | Type | Default |
|---|---|---|---|
label | – | string | – |
rows | – | number | 4 |
#Types
#FaifoGridApi
| Property | Description | Type | Default |
|---|---|---|---|
elementrequired | – | HTMLElement | – |
rowsrequired | The current rows, drafts included, in their saved order. | () => Row[] | – |
changesrequired | – | () => FaifoGridChanges<Row> | – |
postedrequired | – | () => FaifoGridPosted | – |
summaryrequired | – | () => FaifoGridSummary | – |
dirtyrequired | – | () => boolean | – |
issuesrequired | – | () => FaifoGridIssue[] | – |
validaterequired | Shows every check on changed rows (before a save) and returns what must be fixed. | () => FaifoGridIssue[] | – |
setRowsrequired | Replaces the rows and drops drafts and history. | (rows: readonly Row[]) => void | – |
setReadOnlyrequired | Freeze edits while the host saves, preserving the draft. | (value: boolean) => void | – |
applyTransactionrequired | Applies rows changed elsewhere, highlighting changed cells and keeping the reader's drafts. | (transaction: FaifoGridTransaction<Row>) => void | – |
markSavedrequired | Takes the saved rows (or the current ones) as the new server copy. | (rows?: readonly Row[] | undefined) => void | – |
revertrequired | – | () => void | – |
setErrorsrequired | Errors from the server, by row id and column key; editing a cell clears its error. | (errors: Readonly<Record<string, Readonly<Record<string, string>>>>) => void | – |
patchrequired | Writes fields of one row as an undoable draft, such as a price looked up after an edit. | (id: string, values: Partial<Row>) => void | – |
addRowrequired | – | (row?: Row | undefined, index?: number | undefined) => string | null | – |
removeRowsrequired | – | (ids: readonly string[]) => string[] | – |
focusCellrequired | – | (id: string, key: string) => void | – |
setBusyrequired | – | (busy: boolean) => void | – |
undorequired | – | () => void | – |
redorequired | – | () => void | – |
destroyrequired | – | () => void | – |
#FaifoGridCell
| Property | Description | Type | Default |
|---|---|---|---|
idrequired | – | string | – |
keyrequired | – | string | – |
#FaifoGridChangeEvent
| Property | Description | Type | Default |
|---|---|---|---|
reasonrequired | – | string | – |
cellsrequired | – | FaifoGridCell[] | – |
changesrequired | – | FaifoGridChanges<Row> | – |
#FaifoGridChanges
| Property | Description | Type | Default |
|---|---|---|---|
addedrequired | New rows the reader filled in, with their position. Rows added and left empty are not changes. | { id: string; index: number; row: Row }[] | – |
updatedrequired | Existing rows with the fields that differ from the server's copy. | { id: string; row: Row; fields: string[] }[] | – |
removedrequired | – | string[] | – |
orderrequired | Every row id in order, when the reader reordered rows or added one before the end; else null. | string[] | null | – |
#FaifoGridColumn
| Property | Description | Type | Default |
|---|---|---|---|
keyrequired | The column's identity, and the row field it reads unless field names another. | string | – |
labelrequired | – | string | – |
type | – | FaifoGridColumnType | – |
field | – | string | – |
width | Width in CSS pixels; each type has a default. | number | – |
grow | A share of the spare width, as a CSS fraction. A pinned column ignores it. | number | – |
minWidth | – | number | – |
pinned | – | 'start' | 'end' | – |
align | – | 'start' | 'center' | 'end' | – |
editable | Columns are read-only unless they say otherwise; a function decides per row. | boolean | ((row: Row) => boolean) | – |
required | – | boolean | – |
min | – | number | – |
max | – | number | – |
fractionDigits | – | number | – |
currency | Money columns: ISO 4217, defaulting to the grid's currency. | string | – |
options | – | readonly FaifoGridOption[] | – |
optionsFor | Select columns: the options this row may take, among options (a product's units). options still names every value the column shows. | (row: Row) => readonly FaifoGridOption[] | – |
search | Combobox columns: options for what the reader typed, read while they type. | FaifoGridSearch<Row> | – |
placeholder | Muted text in an empty editable cell, such as "Choose a product". | string | – |
hint | A longer description of the column, shown as the header's tooltip. | string | – |
sortable | – | boolean | – |
resizable | – | boolean | – |
value | A computed value. The column is read-only, unless set writes what was typed back into the fields it is computed from (a margin typed sets the price that earns it). | (row: Row) => FaifoGridValue | – |
set | Writes an edited value. Return a new row; it may change other fields too (a product sets its price). | (row: Row, value: FaifoGridValue) => Row | – |
format | – | (value: FaifoGridValue, row: Row) => string | – |
parse | Reads typed or pasted text. Return undefined for text that is not a value of this column. | (text: string, row: Row) => FaifoGridValue | undefined | – |
validate | A message for a value the reader must fix, or null. | (value: FaifoGridValue, row: Row) => string | null | – |
footer | The footer total: the sum of the column, or a value computed from the rows. | 'sum' | ((rows: readonly Row[]) => FaifoGridValue) | – |
#FaifoGridColumnType
type FaifoGridColumnType =
| 'text'
| 'number'
| 'money'
| 'percent'
| 'date'
| 'select'
| 'combobox'
| 'checkbox'#FaifoGridFullWidth
A row shown as one cell: a section heading or a note, with a short tag after its text (Optional).
| Property | Description | Type | Default |
|---|---|---|---|
keyrequired | – | string | – |
tonerequired | – | 'section' | 'note' | – |
tag | – | string | null | – |
#FaifoGridIslandColumn
A column as island props: data only, so it crosses from the server as JSON.
| Property | Description | Type | Default |
|---|---|---|---|
keyrequired | The column's identity, and the row field it reads unless field names another. | string | – |
labelrequired | – | string | – |
type | – | FaifoGridColumnType | – |
field | – | string | – |
width | Width in CSS pixels; each type has a default. | number | – |
grow | A share of the spare width, as a CSS fraction. A pinned column ignores it. | number | – |
minWidth | – | number | – |
pinned | – | 'start' | 'end' | – |
align | – | 'start' | 'center' | 'end' | – |
required | – | boolean | – |
min | – | number | – |
max | – | number | – |
fractionDigits | – | number | – |
currency | Money columns: ISO 4217, defaulting to the grid's currency. | string | – |
options | – | readonly FaifoGridOption[] | – |
optionsFor | Select columns: the options this row may take, among options (a product's units). options still names every value the column shows. | (row: Row) => readonly FaifoGridOption[] | – |
placeholder | Muted text in an empty editable cell, such as "Choose a product". | string | – |
hint | A longer description of the column, shown as the header's tooltip. | string | – |
sortable | – | boolean | – |
resizable | – | boolean | – |
editable | – | boolean | – |
compute | A value worked out from the row (FaifoGridCompute): a line's subtotal, margin or margin %, or one field less another (a count's difference), empty while either is. | FaifoGridCompute | – |
footer | – | 'sum' | { decimalSum: number } | – |
lockedBy | A row field that, when set (true, a non-zero number, text), makes this column read-only on that row, such as a product already delivered. | string | – |
requires | A row field that must be set before this column opens on that row: a unit waits for its product. | string | – |
minField | A row field holding the smallest value this column takes on that row, such as what was delivered. | string | – |
maxField | A row field holding the largest value this column takes on that row, such as what is still due. | string | – |
sumEquals | Cross-field quantity validation, shown at the edited cell while retaining its draft. | { fields: readonly string[]; total: string; message: string } | – |
optionsBy | Select columns: a row field whose value picks the options that row may take, such as a product's units by product. A value values does not name leaves every option. | { field: string; values: Readonly<Record<string, readonly string[]>> } | – |
sets | Fields a choice also writes into its row, by option value: a product's description, unit and price. | Readonly<Record<string, FaifoGridRow>> | – |
writeSets | Constant dependent fields written after a successful edit, including a computed inverse. | FaifoGridRow | – |
resets | Clear dependent fields when this cell changes (a SKU clears its unit and automatic price). | readonly string[] | – |
search | Combobox columns read options from a KetJS function (POST /_ket/fn/<name>) as the reader types. | { listFunction: string listInput?: Record<string, unknown> /** Required function inputs read from this row; no request until every parent is set. */ listInputFields?: Readonly<Record<string, string>> searchParam?: string limitParam?: string limit?: number idField?: string labelField?: string /** Fallback for records without the compact identifier used as their cell label. */ labelFallbackField?: string descriptionField?: string /** Trusted remote option fields copied into row fields on selection, scoped by listInputFields. */ setsFrom?: Readonly<Record<string, string>> } | – |
#FaifoGridIslandConfig
| Property | Description | Type | Default |
|---|---|---|---|
labelrequired | – | string | – |
columnsrequired | – | readonly FaifoGridIslandColumn[] | – |
rowsrequired | – | readonly FaifoGridRow[] | – |
idField | The row field holding its id. Defaults to id. | string | – |
labels | – | Partial<FaifoGridLabels> | – |
locale | – | string | – |
currency | – | string | – |
density | – | 'compact' | 'default' | 'comfortable' | – |
visibleRows | – | number | – |
height | – | string | – |
readOnly | – | boolean | – |
newRow | A new row's starting values; lets the reader add rows. | FaifoGridRow | – |
newRows | Several kinds of new row, each with its own add button (a line, a section, a note); replaces newRow. | readonly { label: string; row: FaifoGridRow }[] | – |
removable | – | boolean | – |
reorderable | – | boolean | – |
kindField | A row field whose value section or note shows the row as one full-width cell of fullWidthKey. | string | – |
fullWidthKey | – | string | – |
fullWidthTag | A row field that, when set on a section or note, shows label after its text, as an optional section. | { field: string; label: string } | – |
lockedField | A row field that, when true, makes the row read-only and keeps it from being removed. | string | – |
keptField | A row field that, when set, keeps the row from being removed while it stays editable, such as a line something was already recorded against. | string | – |
tiers | Fields a row takes in steps of another field, as a product's price by quantity: the row's key field picks a list of steps, and the step with the largest from at most the row's by field writes its fields. Applied after sets whenever either field is edited; a row whose lockedBy field is set (a line already delivered) keeps its fields. With with (a product's unit), the steps of <key>|<with> come first, then those of the key alone; editing with steps the row too. | { key: string by: string with?: string lockedBy?: string | readonly string[] steps?: Readonly<Record<string, readonly { from: number; row: FaifoGridRow }[]>> /** A row-owned array of steps supplied by a remote picker, preferred over static steps. */ stepsField?: string } | – |
errors | Server-owned messages keyed by stable grid row ID and column key, applied after restoring carry. | Readonly<Record<string, Readonly<Record<string, string>>>> | – |
totals | Live exact totals; compareTo is a server-supplied fact, never a posted authority. | readonly { key: string label: string digits?: number compareTo?: string differenceLabel?: string }[] | – |
name | – | string | – |
form | – | string | – |
carry | An earlier posted value of this grid, as the JSON text a record draft keeps; see carry. | string | FaifoGridPosted | null | – |
draftFlags | User-owned boolean intent carried with drafts; never authorization or lock metadata. | readonly string[] | – |
#FaifoGridIssue
| Property | Description | Type | Default |
|---|---|---|---|
idrequired | – | string | – |
keyrequired | – | string | – |
tonerequired | – | 'danger' | 'warning' | – |
messagerequired | – | string | – |
#FaifoGridLabels
| Property | Description | Type | Default |
|---|---|---|---|
loadingrequired | – | string | – |
emptyrequired | – | string | – |
addRowrequired | – | string | – |
removeRowsrequired | – | string | – |
undorequired | – | string | – |
redorequired | – | string | – |
totalrequired | – | string | – |
dragHandlerequired | – | string | – |
instructionsrequired | – | string | – |
requiredrequired | – | string | – |
invalidNumberrequired | – | string | – |
invalidDaterequired | – | string | – |
invalidOptionrequired | – | string | – |
invalidValuerequired | – | string | – |
belowMinrequired | {min} is the formatted minimum. | string | – |
aboveMaxrequired | {max} is the formatted maximum. | string | – |
conflictrequired | {value} is the value set elsewhere. | string | – |
keepMinerequired | – | string | – |
takeTheirsrequired | – | string | – |
removedElsewhererequired | – | string | – |
searchingrequired | – | string | – |
noOptionsrequired | – | string | – |
searchFailedrequired | – | string | – |
addedRowsrequired | {count} placeholders below. | string | – |
editedCellsrequired | – | string | – |
removedRowsrequired | – | string | – |
otherPagesrequired | Rows changed in an earlier view of this grid (another page) that the next save still posts. | string | – |
errorsrequired | – | string | – |
conflictsrequired | – | string | – |
copiedrequired | – | string | – |
pastedrequired | – | string | – |
pasteSkippedrequired | – | string | – |
rowAddedrequired | – | string | – |
rowsRemovedrequired | – | string | – |
fixBeforeSavingrequired | Said when a form holding the grid is kept from submitting. | string | – |
rowMovedrequired | – | string | – |
undonerequired | – | string | – |
redonerequired | – | string | – |
sortedAscendingrequired | {column} is the column's label. | string | – |
sortedDescendingrequired | – | string | – |
sortClearedrequired | – | string | – |
readOnlyCellrequired | – | string | – |
yesrequired | – | string | – |
norequired | – | string | – |
#FaifoGridOption
| Property | Description | Type | Default |
|---|---|---|---|
valuerequired | – | string | – |
labelrequired | – | string | – |
description | – | string | null | – |
#FaifoGridOptions
| Property | Description | Type | Default |
|---|---|---|---|
labelrequired | The grid's accessible name. | string | – |
columnsrequired | – | readonly FaifoGridColumn<Row>[] | – |
rowsrequired | – | readonly Row[] | – |
rowIdrequired | – | (row: Row) => string | – |
labels | – | Partial<FaifoGridLabels> | – |
locale | BCP 47; defaults to the document's language. | string | – |
currency | ISO 4217 for money columns; defaults to VND. | string | – |
density | – | 'compact' | 'default' | 'comfortable' | – |
visibleRows | Rows in view before the grid scrolls, without a fixed height. Defaults to 12. | number | – |
height | A fixed CSS height for the scrolling area, such as 100% inside a sized region. | string | – |
readOnly | – | boolean | – |
rowEditable | – | (row: Row) => boolean | – |
createRow | Lets the reader add rows; returns a new row's starting values. | (context: { index: number }) => Row | – |
newRows | Several kinds of new row (a line, a section, a note), each with its own button; the first is what Ctrl+Enter adds. Takes the place of createRow. | readonly { label: string; create: (context: { index: number }) => Row }[] | – |
removable | Lets the reader remove rows; a function decides per row. | boolean | ((row: Row) => boolean) | – |
reorderable | Lets the reader reorder rows by dragging the handle and with Alt+↑/↓. | boolean | – |
fullWidth | A row shown as one full-width cell, such as a section heading or a note, editing one column. | (row: Row) => FaifoGridFullWidth | null | – |
name | Posts the changes as JSON (FaifoGridPosted) in a hidden field with this name. The field counts as the reader's input (a form tracking unsaved edits sees it), and while a changed cell holds a wrong value the form does not submit, unless it or its submitter is novalidate. | string | – |
form | The form that hidden field belongs to, when the grid sits outside it. | string | – |
carry | What an earlier posted() of this grid held, such as a record draft kept while the reader changed page. Updates to rows shown here are drafts again; updates to other rows ride along in what the grid posts, so one save keeps every page's edits. Structural edits and learned option labels are retained when allowed by the grid capabilities. | FaifoGridPosted | null | – |
draftFlags | Explicit user-owned boolean modes, validated again by the domain writer. | readonly string[] | – |
errors | – | Readonly<Record<string, Readonly<Record<string, string>>>> | – |
summary | – | (rows: readonly Row[]) => string | – |
onChange | – | (event: FaifoGridChangeEvent<Row>) => void | – |
onActiveCellChange | – | (cell: FaifoGridCell | null) => void | – |
#FaifoGridPosted
What a form posts for the grid: the changes, with only the changed fields of updated rows.
| Property | Description | Type | Default |
|---|---|---|---|
optionLabels | Display-only labels retained with a form draft. Never authoritative server input. | Record<string, Record<string, string>> | – |
addedrequired | – | { id: string; index: number; values: FaifoGridRow }[] | – |
updatedrequired | – | { id: string; values: FaifoGridRow }[] | – |
removedrequired | – | string[] | – |
orderrequired | – | string[] | null | – |
#FaifoGridRow
type FaifoGridRow = Record<string, unknown>#FaifoGridSearch
type FaifoGridSearch<Row> = (
query: string,
context: { row: Row; signal: AbortSignal },
) => Promise<readonly FaifoGridOption[]>#FaifoGridSummary
| Property | Description | Type | Default |
|---|---|---|---|
addedrequired | – | number | – |
editedrequired | – | number | – |
removedrequired | – | number | – |
errorsrequired | – | number | – |
conflictsrequired | – | number | – |
#FaifoGridTransaction
| Property | Description | Type | Default |
|---|---|---|---|
add | – | readonly Row[] | – |
update | – | readonly Row[] | – |
remove | – | readonly string[] | – |
#FaifoGridValue
type FaifoGridValue = string | number | boolean | null#Hooks
The data-ui values these components render. Select them in tests and behaviour; their look belongs to the design system. See Contract.
faifo-gridfaifo-grid-islandfg-placeholderfg-viewportfg-headerfg-header-cellfg-header-labelfg-sortfg-resizefg-bodyfg-spacerfg-rowfg-cellfg-cell-valuefg-checkfg-flagfg-handlefg-dropfg-emptyfg-footerfg-editorfg-popupfg-optionsfg-options-statusfg-optionfg-option-labelfg-option-descriptionfg-messagefg-message-actionsfg-toolsfg-statusfg-value