gridMulti
A grid where every row can hold multiple selections from a shared scale. Use × scale matrices, channel × purpose tables, feature × audience grids.
What gridMulti is
gridMulti shows a table with one row per item and one column per
scale point. Each row stores a collection of selected scale codes
— zero, one, or many. Common shape: items down the rows, an
“applies to all that apply” scale across the columns. Selection
counts are bounded per row by min / max / exact.
- qid: QChannels
type: gridMulti
text: Where do you use each channel?
instruction: Tick all that apply.
options:
1: Email
2: Phone
3: SMS
scale:
1: At home
2: At work
3: On the go
Properties
| Property | Values | Notes |
|---|---|---|
qid | string | Required. Unique within the survey. |
type | gridMulti | Required. |
title, text, instruction | renderable | Visible content. Use {{ }} to pipe runtime values. HTML allowed. |
required | True | False | Default True. |
default.errors | True | False | custom string | Default True. |
validation | code block | Python; call fail() to reject. No default. |
readonly | True | False | Default False. Set True to render the question but disable input — the respondent sees the rows but can’t change the values. Pair with visibility: hide to fully hide a helper question. |
visibility | show | hide | Default show. |
style | checkboxGrid | cardStack | chipGrid | Default checkboxGrid. See Styles below. |
order | fixed | random | randomEach | flip | alphabetical | reverse | Default fixed. Row order. |
group.order | same as order | Default fixed. Order of named row groups. |
scale.order | same as order | Default fixed. Order of scale columns. |
scale.repeat | top | bottom | both | sticky | Default top. Where the scale-label header is repeated in long grids. |
scale.repeat.every | integer (≥ 1) | Cadence — repeat the scale labels every N rows. |
layout.cols | integer | Default 1. |
layout.width | string | Custom width override. |
label.position | default | left | right | Where the row label sits relative to the inputs. |
min | integer | Minimum selections per row. No default. |
max | integer | Maximum selections per row. No default. |
exact | integer | Exactly this many selections per row. Overrides min/max. No default. |
options | list name or inline domain | Required when group: is not used. The rows. |
options.from | expression | Filter the visible rows at runtime. No default. |
group | grouped list name | Required when options: is not used. |
scale | list name or inline domain | Required. The columns (scale points). |
scale.from | expression | Filter the visible scale columns at runtime. No default. |
custom | code block | Custom runtime block. No default. |
data | object | Metadata object for advanced authoring. No default. |
min / max / exact are per-row. Each row independently must meet the selection-count constraint. min: 1 means every row must have at least one tick; it does not mean “at least one row must be answered overall”.Group properties
When using group: to subdivide rows:
| Property | Values | Notes |
|---|---|---|
options | grouped row entries | Required. |
show.label | True | False | Default True. Set False to hide the group header. |
anchor | True | False | Default False. Set True to pin the group in place under group.order: random. |
Per-row properties
Expand a row to a map to attach extra behaviour.
| Property | Values | Notes |
|---|---|---|
label | renderable | Required when expanding the row. |
anchor | True | False | Default False. Pin in place under order: random. |
exclusive | True | False | Default False. Set True to make the row mutually exclusive within itself — only one scale code can be ticked in this row at a time. Picking a new cell collapses the row’s selection to just that code. Other rows are unaffected. Useful when a particular row should behave like single-select while the rest of the grid stays multi-select. |
Per-scale properties
Expand a scale entry to a map to attach extra behaviour.
| Property | Values | Notes |
|---|---|---|
label | renderable | Required when expanding the scale entry. |
anchor | True | False | Default False. Pin in place under scale.order: random. |
exclusive | True | False | Default False. When ticked in a given row, every other scale code in that row is cleared. Typical “Not applicable” / “None of these” pattern, scoped per row. |
Methods & accessors
Accessors
Question accessors
| Expression | Returns | Meaning |
|---|---|---|
Q.all | CodeSet | All visible row codes (the row domain). |
Q.allLabels | LabelList | Labels for Q.all. |
Q.answered | bool | True if any row has at least one selection. |
Q.notAnswered | bool | Inverse. |
selected on gridMulti. Selections are per-row only. To check “did any row pick code N?”, walk Q.all: any(Q.row(c).selected.any(N) for c in Q.all).Row accessors
Q.row(N) returns a row proxy. N is the row code (not a position).
| Expression | Returns | Meaning |
|---|---|---|
Q.row(N).selected | CodeSet | Collection of scale codes ticked in row N. |
Q.row(N).selectedLabels | LabelList | Labels for Q.row(N).selected. |
Q.row(N).label | Label | The row’s own label. |
Q.row(N).all | CodeSet | The full visible scale domain (same for every row). |
Q.row(N).allLabels | LabelList | Labels for the visible scale domain. |
Q.row(N).answered | bool | True once row N has at least one selection. |
Q.row(N).notAnswered | bool | Inverse. |
Methods
Question methods
| Expression | Returns | Meaning |
|---|---|---|
Q.reset() | None | Clear every row. |
Q.row(N) | RowObject | Returns a row proxy for row code N. |
Q.at(N) | RowObject | Same as Q.row(N). |
Q.set({...}) accepts a bulk-update form for setting many rows at
once. See Advanced below.
Row methods
| Expression | Returns | Meaning |
|---|---|---|
Q.row(N).set([1, 2]) | None | Set row N’s selection to a list of scale codes. Replaces whatever was there. |
Q.row(N).add(M) | None | Add scale code M to row N’s existing selection. |
Q.row(N).reset() | None | Clear row N. |
Q.row(N).col(M) | CellObject | (Advanced) cell-level proxy for the (row, scale) intersection. |
Collection operations
Q.row(N).selected and Q.row(N).selectedLabels are collections,
plus the question-level Q.all/Q.allLabels. Standard ops apply:
| Expression | Returns | Meaning |
|---|---|---|
Q.row(N).selected.size | int | Number of scale codes ticked in row N. |
Q.row(N).selected.any(M) | bool | True if row N ticked code M. The most-used routing pattern. |
Q.row(N).selected.any([2, 3]) | bool | True if row N ticked any of the listed codes. |
Q.row(N).selected.every([1, 2]) | bool | True if row N ticked all the listed codes. |
Q.row(N).selected.intersect([2, 3]) | CodeSet | New collection of overlap. |
Q.row(N).selected.union(other) | CodeSet | Combine collections. |
Q.row(N).selected.minus([99]) | CodeSet | Selection minus the listed codes. |
Q.all.size | int | Number of visible rows. |
For aggregate counts (“how many rows ticked code N?”) write a script:
sum(1 for c in Q.all if Q.row(c).selected.any(N)).
Skins
Three visual styles. Pick by row count, label length, and device.
checkboxGrid Checkbox grid (default) cardStack Card stack chipGrid Chip grid The exact appearance is driven by theme tokens — colours, radii, fonts. See Customisation and Skin variants.
See it work
A working preview. Tick cells and watch the Live state panel.
QFeatures.answeredFalseQFeatures.valueNoneQFeatures.selected{}QFeatures.selectedLabelNoneQFeatures.selected.size0QFeatures.answeredFalseQFeatures.row(1).selected{}QFeatures.row(1).selected.size0QFeatures.all.size0- qid: QFeatures
type: gridMulti
text: Which features do you use on each device?
instruction: Tick all that apply per device.
options:
1: Phone
2: Tablet
3: Desktop
scale:
1: Voice search
2: Maps
3: Camera
4: Calendar
The state panel shows row 1’s selection live — the playground below has the full per-row view.
Methods & accessors — live
Tick cells and watch each expression evaluate.
QFeatures.answered → — QFeatures.row(1).selected → — QFeatures.row(1).selected.size → — QFeatures.row(1).answered → — QFeatures.row(1).label → — QFeatures.row(1).selected.any(3) → — QFeatures.row(1).selected.any([1, 2]) → — QFeatures.row(1).selected.every([1, 2]) → — QFeatures.row(2).selected.intersect([1, 2, 3]) → — A few things to notice:
Q.row(N).selectedis a collection per row, not a single code..sizeis the count of ticks in that row;.any(M)/.every([list])/.intersect(...)all work as expected.- There’s no question-level
Q.selected. To answer “did any row tick code N?”, walkQ.all:any(Q.row(c).selected.any(N) for c in Q.all). Q.row(N).labelis the row’s own label (e.g. “Phone”); scale labels live on the scale entries, accessed viaQ.row(N).allLabels.
Examples
”Tick at least 2 per row”
- qid: QChannels
type: gridMulti
text: Where do you use each channel?
min: 2
options:
1: Email
2: Phone
3: SMS
scale:
1: At home
2: At work
3: On the go
4: Don't use
min: 2 applies to every row. The respondent must tick at least
two scale points for each row.
”None of these” exclusive scale entry
- qid: QFeatureUse
type: gridMulti
text: Which features matter on each device?
options:
1: Phone
2: Tablet
3: Desktop
scale:
1: Voice search
2: Maps
3: Camera
4:
label: Don't use any
exclusive: True
Picking code 4 on a row clears the other ticks in that row
only. Exclusive scale items scope per row, not across rows.
Per-row routing
- qid: QChannels
type: gridMulti
options: channelList
scale: contextScale
- qid: QPhoneFollow
type: open
text: Tell us about your phone usage.
if: QChannels.row(2).selected.any([1, 2, 3]) # row 2 = Phone
style: textarea
QPhoneFollow only shows when row 2 (Phone) has at least one
non-”Don’t use” selection. The grid’s per-row routing makes this
trivial.
Aggregate count across rows
- qid: QFeatures
type: gridMulti
options: deviceList
scale: featureList
- qid: hVoiceUsers
type: number
visibility: hide
readonly: True
required: False
- script: |
# Count devices where the respondent ticked Voice search.
voice = sum(1 for c in QFeatures.all if QFeatures.row(c).selected.any(1))
hVoiceUsers.set(voice)
hVoiceUsers exports as a clean count for cross-tabbing — number
of devices used for voice across all rows.
Pipe a row’s selected labels
- qid: QFeatures
type: gridMulti
options: deviceList
scale: featureList
- qid: QPrimary
type: open
text: You said your Phone is used for {{ QFeatures.row(1).selectedLabels }}. Which is most important?
if: QFeatures.row(1).answered
style: text
row(N).selectedLabels stringifies as "Voice search", "Maps" for
piping. Use selectedLabels.at(0) for just the first.
Validation example
- qid: QFeatures
type: gridMulti
text: Which features matter on each device?
options: deviceList
scale: featureScale
validation: |
# Require at least one tick on the Phone row specifically.
if not QFeatures.row(1).answered:
fail("Please tick at least one feature for Phone.")
# And reject "Don't use" combined with another tick on the same row.
for c in QFeatures.all:
sel = QFeatures.row(c).selected
if sel.any(99) and sel.size > 1:
fail("If you tick 'Don't use any', untick the others on that row.")
break
Custom validation can target specific rows or walk every row.
Advanced
Bulk Q.set({…}) — set many rows in one call
The everyday way to write a gridMulti from a script is per-row
(QFeatures.row(1).set([1, 2])). When a script has values for many
rows ready at once, the bulk form applies them in one go:
QFeatures.set({
1: [1, 2, 3], # row 1: codes 1, 2, 3
2: [2, 4], # row 2: codes 2, 4
3: [], # row 3: cleared
})
QFeatures.set({}) # clear every row
Object keys are row codes; values are lists of scale codes for each row. Unknown row or scale codes throw.
Why bulk set exists
Same rationale as on gridSingle
— atomicity (whole payload validates together), mirroring
data from another source, derived state computed from other
questions, and a small performance edge in hot scripts. Prefer
the per-row form for one or two writes.
Example — copy a previous-wave grid forward
- qid: QPrev
type: gridMulti
options: deviceList
scale: featureList
- qid: QCurrent
type: gridMulti
options: deviceList
scale: featureList
- script: |
# Pre-fill the current-wave grid with what the respondent said
# last time. They confirm or adjust.
payload = {
c: list(QPrev.row(c).selected)
for c in QPrev.all
if QPrev.row(c).answered
}
QCurrent.set(payload)
Cell-level access — Q.row(N).col(M)
For inspecting individual (row, scale) intersections without
touching the surrounding row, use Q.row(N).col(M) — returns a
cell proxy whose primary accessor is .selected (a bool).
if QFeatures.row(1).col(3).selected:
# row 1 (Phone) ticked code 3 (Camera)
print("Phone uses Camera")
In practice this is rarely worth using over
Q.row(N).selected.any(M) — but it exists for code that wants to
read or write a specific cell explicitly.
Export
gridMulti fans out to one column per (row, scale) intersection:
| What | Column |
|---|---|
| Row N, scale code M ticked? | qidrNoM (e.g. QChannelsr1o2) |
Each column is tri-state:
| Value | Meaning |
|---|---|
1 | The cell was shown to the respondent and ticked. |
0 | The cell was shown to the respondent and not ticked. |
null | The cell was not shown — masked by options.from / scale.from, or skipped via if. |
The distinction matters whenever you mask rows or columns at runtime. See Tri-state projection.
See also
- gridSingle — one selection per row.
- gridNumber — numeric values per cell (rows × cols).
- multi — when there’s only one row.
- Conditional & dynamic —
options.from,scale.from. - Tri-state projection — what
nullmeans in the export. - Collections — full method reference.