Skip to content

Checking and output modes ​

What this page covers ​

Checking lives in assembly/tree-check.ts and dispatches on selectType into three quite different semantics:

SelectTypeBehaviour
CHECKBOXSets the target node and its whole subtree, then walks every ancestor once, recomputing checked (CHECKED / HALF_CHECKED / UNCHECKED) from its direct children
RADIOExactly one node in the whole tree is checked at a time
SELECTClick-to-select; also unique tree-wide, but it uses the selected field and leaves checkbox state alone

Two behaviours that are easy to miss:

  • Disabled nodes cannot be selected: if the target node is disabled, the operation returns immediately — not even its subtree changes.
  • Ancestor recomputation is idempotent: every ancestor is recomputed from its children's current values rather than by accumulating deltas, so checking the same node twice cannot drift the half-checked state.

Parameters ​

propTypeDefaultDescription
selectTypeSelectTypeSelectType.CHECKBOXCHECKBOX / RADIO / SELECT
outputIdOnlybooleantruetrue gives only the IDs of checked nodes in v-model; false gives full TreeNodeData
checkedOutputModeCheckedOutputModeCheckedOutputMode.AllIn CHECKBOX mode, which checked nodes reach the output
filterFnFilterFn—Custom filter callback, see the table below
modelValueTreeNodeData | TreeNodeData[] | string | string[]—The selection (v-model)

CheckedOutputMode ​

ValueOutput
AllEvery checked node
RootOnlyOnly the roots of fully-checked subtrees (deduped to the topmost)
LeafOnlyOnly leaf nodes
CustomDecided by filterFn

What filterFn does in each mode ​

ModeEffect
CHECKBOX + CustomFilters the output: a checked node whose filterFn returns false never reaches v-model
RADIOFilters selectability: a node whose filterFn returns false shows no radio button
SELECTNot affected

filterFn receives the node's extendData (a full copy of the raw row), not a TreeNodeData.

Usage ​

Only the checked IDs (the default):

vue
<VueGiantTree :tree="rows" root="root" v-model="selectedIds" />
<!-- selectedIds: ['2', '3'] -->

Full node content:

vue
<VueGiantTree :tree="rows" root="root" :output-id-only="false" v-model="selectedRows" />
<!-- selectedRows: [{ id: '2', name: 'Child A', ... }] -->

Only the roots of fully-checked subtrees:

vue
<VueGiantTree
  :tree="rows"
  root="root"
  :checked-output-mode="CheckedOutputMode.RootOnly"
  v-model="selectedIds"
/>

Try it ​

Try it: check the root node, then switch "Output mode" — the panel goes from "every checked node" to "only the root" or "only leaves". Switch to RADIO and the same data shows radio buttons instead, with at most one selected.