gridSingle
A grid where every row gets one selection from a shared scale. Rating tables, satisfaction matrices, agreement scales, semantic differentials.
What gridSingle is
gridSingle shows a table with one row per item and one column per
scale point. Each row stores one selected scale code. Common
shape: items down the rows, a Likert-style scale across the columns.
The two domains are independent — options (or group) defines the
rows, scale defines the columns.
- qid: QSatisf
type: gridSingle
text: How satisfied are you with each?
instruction: One answer per row.
options:
1: Service
2: Price
3: Reliability
4: Selection
scale:
1: Very dissatisfied
2: Dissatisfied
3: Neutral
4: Satisfied
5: Very satisfied
Properties
| Property | Values | Notes |
|---|---|---|
qid | string | Required. Unique within the survey. |
type | gridSingle | 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 | radioGrid | paired | scaleButtons | cardStack | emojiScale | sliderGrid | bipolarSlider | scaleBar | Default radioGrid. 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: at the top, at the bottom, at both ends, or pinned (sticky) so it stays visible while the respondent scrolls. |
scale.repeat.every | integer (≥ 1) | Cadence for the repetition — 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. |
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. |
options.from filters which rows are shown to a respondent (e.g. only ranked brands); scale.from filters which scale columns are shown (e.g. drop “Don’t know” if a previous answer ruled it out). They’re independent.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. |
left.label | renderable | Used with style: paired or style: bipolarSlider. The label at the left end of this row’s scale (or slider). |
right.label | renderable | Used with style: paired or style: bipolarSlider. The label at the right end of this row’s scale (or slider). |
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. |
Methods & accessors
Accessors
Question accessors
| Expression | Returns | Meaning |
|---|---|---|
Q.values | CodeList | Selected scale codes per row, in row order. null for unanswered rows. |
Q.selected | CodeSet | Deduplicated set of scale codes used across all rows. Useful for “did the respondent ever pick code N?”. |
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 a selection. |
Q.notAnswered | bool | Inverse. |
Row accessors
Q.row(N) returns a row proxy. N is the row code (not a position).
| Expression | Returns | Meaning |
|---|---|---|
Q.row(N).value | Code | The scale code chosen for row N. None if the row is unanswered. |
Q.row(N).selected | CodeSet | Collection containing the row’s chosen scale code (size 0 or 1). |
Q.row(N).selectedLabel | Label | The display label of the chosen scale code. None if unanswered. |
Q.row(N).label | Label | The row’s own label (the option label, not the scale). |
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 a 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(M) | None | Set row N to scale code M. |
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.selected, Q.values, Q.all, Q.allLabels, and the per-row
Q.row(N).selected are all collections. Standard ops apply:
| Expression | Returns | Meaning |
|---|---|---|
Q.row(N).selected.any(M) | bool | True if row N chose scale code M. The most-used routing pattern. |
Q.row(N).selected.any([3, 4, 5]) | bool | True if row N’s answer is in the listed range. |
Q.selected.any(M) | bool | True if any row chose code M. |
Q.values.size | int | Number of visible rows (the row domain size). |
Q.all.size | int | Same as Q.values.size. |
For “how many rows answered” use a script:
sum(1 for c in Q.all if Q.row(c).answered).
Skins
Seven visual styles, each suited to a different context — desktop matrix, mobile cards, sentiment scales, sliding scales, semantic differentials.
radioGrid Radio grid (default) paired Paired scaleButtons Scale buttons cardStack Card stack emojiScale Emoji scale sliderGrid Slider grid bipolarSlider Bipolar slider scaleBar Scale bar The exact appearance is driven by theme tokens — colours, radii, fonts. See Customisation and Skin variants.
See it work
A working preview. Pick a scale point on each row and watch the Live state panel.
QFeatures.answeredFalseQFeatures.valueNoneQFeatures.selected{}QFeatures.selectedLabelNoneQFeatures.selected.size0QFeatures.answeredFalseQFeatures.values{}QFeatures.selected{}QFeatures.all.size0- qid: QFeatures
type: gridSingle
text: Rate each feature.
instruction: One answer per row.
options:
1: Battery life
2: Camera quality
3: Screen size
scale:
1: Poor
2: OK
3: Good
4: Excellent
The Live state panel shows values (one scale code per row, with
null for unanswered) and selected (the deduplicated set of scale
codes used). Pick the same code on two rows and notice selected is
deduplicated; values keeps both.
Methods & accessors — live
Pick scale points on the rows below and watch each expression evaluate.
QSatisf.answered → — QSatisf.values → — QSatisf.selected → — QSatisf.row(1).value → — QSatisf.row(1).label → — QSatisf.row(1).selectedLabel → — QSatisf.row(1).answered → — QSatisf.row(1).selected.any(4) → — QSatisf.row(1).selected.any([3, 4]) → — QSatisf.selected.any(1) → — A few things to notice:
Q.row(N).selected.any(M)is the canonical routing pattern. “Did row 1 get rated4?” reads asQSatisf.row(1).selected.any(4).Q.row(N).labelis the row’s label (“Service”);.selectedLabelis the chosen scale’s label (“Good”). Same word, different domain.Q.valuesis per-row, in row order, withnullfor unanswered rows.Q.selectedis the deduplicated set across all rows — useful for “was code4ever picked”.- The row-level
.allreturns the scale domain (same for every row). The question-level.allreturns the row domain.
Examples
Top-box scoring
- qid: QSatisf
type: gridSingle
text: How satisfied are you with each?
options:
1: Service
2: Price
3: Reliability
scale:
1: Very dissatisfied
2: Dissatisfied
3: Neutral
4: Satisfied
5: Very satisfied
- qid: hTopBox
type: number
visibility: hide
readonly: True
required: False
- script: |
# Count rows where the respondent picked Satisfied or Very satisfied.
top = sum(1 for c in QSatisf.all if QSatisf.row(c).selected.any([4, 5]))
hTopBox.set(top)
hTopBox exports as a clean number — useful when downstream
analysis wants top-2-box counts as a column.
Conditional follow-up per row
- qid: QSatisf
type: gridSingle
options: featureList
scale: satisfactionScale
- qid: QWhyService
type: open
text: What would have made the service better?
if: QSatisf.row(1).selected.any([1, 2]) # row 1 = Service, rated low
style: textarea
QWhyService only shows when the respondent rated Service
specifically as Dissatisfied or Very dissatisfied. The grid’s
per-row routing makes this kind of targeting trivial.
Pipe a row’s chosen label
- qid: QSatisf
type: gridSingle
options: featureList
scale: satisfactionScale
- qid: QHighlight
type: open
text: You said "{{ QSatisf.row(1).selectedLabel }}" for Service. Tell us why.
if: QSatisf.row(1).answered
style: textarea
row(N).selectedLabel returns the chosen scale’s label, which is
usually what you want in piped text.
Mask scale columns at runtime
- qid: QFamiliar
type: single
text: How familiar are you with the brand?
options:
1: Not at all
2: A little
3: Very
- qid: QRate
type: gridSingle
text: Rate the brand on each.
options: brandFeatures
scale:
1: Bad
2: OK
3: Good
4: Excellent
99: Don't know
# Show "Don't know" only to respondents who said "Not at all" / "A little"
scale.from: scaleBase if QFamiliar.selected.any(3) else scaleBase + [99]
scale.from filters the column dimension. The runtime expression
returns a list of scale codes; only those columns render.
All-same detection (for data-quality flags)
- script: |
# Flag straight-liners — same answer on every row.
answered = [QSatisf.row(c).value for c in QSatisf.all if QSatisf.row(c).answered]
if len(answered) >= 3 and len(set(answered)) == 1:
hStraightLiner.set(1)
else:
hStraightLiner.set(0)
Useful for data quality flags downstream.
Validation example
- qid: QSatisf
type: gridSingle
text: Rate each.
options: featureList
scale: satisfactionScale
validation: |
# Don't accept the survey if Service is rated "Don't know" — we want a real opinion.
if QSatisf.row(1).selected.any(99):
fail("Please rate the Service item — pick a satisfaction level.")
Advanced
Bulk Q.set({…}) — set many rows in one call
The everyday way to write a gridSingle from a script is per-row:
QSatisf.row(1).set(4). When a script needs to write several
rows at once, the bulk form is a single call:
QSatisf.set({1: 4, 2: 5, 3: 3}) # row 1 → 4, row 2 → 5, row 3 → 3
QSatisf.set({}) # clear every row (alias for reset())
The keys are row codes; the values are scale codes. Unknown row or scale codes throw.
Why bulk set exists
For one or two rows the per-row form (QSatisf.row(1).set(4)) is
fine. The bulk form earns its place when the script is doing
aggregate work:
- Atomicity. Every key in the object lands in one go. Either the whole payload validates and is applied, or none of it is — partial updates from a failing payload aren’t possible. Useful when several rows depend on each other.
- Mirroring another data source. Pre-fill from a previous wave, copy from another grid, hydrate from JS-fed values. The script builds the object once and pushes it.
- Computed-from-elsewhere answers. When a hidden grid’s
every-row state is derived from other questions, building a dict
and calling
set()once reads cleaner than many per-row calls. - Performance in hot scripts. A single
set()runs one validation pass instead of N. For a 30-row grid in a tight loop, that adds up.
If none of those apply, prefer the per-row form — it’s clearer at the call site.
Example — pre-fill from a previous wave
- script: |
# `request.params` is the URL-fed context for this respondent.
# Their previous wave's grid answer arrives as a JSON string.
import json
prev = json.loads(request.params.get("prev_satisf") or "{}")
if prev:
# Keys come in as strings; cast to int row codes.
QSatisf.set({int(k): int(v) for k, v in prev.items()})
The respondent lands on the survey with their previous answers already filled in, ready to confirm or change. One call applies the whole grid.
Example — derive ratings from another question
- qid: QRank
type: rank
text: Rank these features.
options: featureList
exact: 5
- qid: hRatings
type: gridSingle
options: featureList
scale: scoreScale
visibility: hide
readonly: True
required: False
- script: |
# Convert rank order to top-down scores: 1st → 5, 2nd → 4, ..., 5th → 1.
payload = {}
for i, code in enumerate(QRank.selected):
payload[code] = 5 - i # 5, 4, 3, 2, 1
if payload:
hRatings.set(payload)
hRatings becomes a gridSingle whose row-by-row scale codes are
derived from the rank order — useful when downstream analysis wants
both views and the rank is the primary capture.
Example — copy a grid forward
- qid: QPrevious
type: gridSingle
options: featureList
scale: satisfactionScale
- qid: QCurrent
type: gridSingle
options: featureList
scale: satisfactionScale
- script: |
# Seed "Current" with the same answers the respondent gave for "Previous".
# The respondent can then adjust where their satisfaction has changed.
payload = {
c: QPrevious.row(c).value
for c in QPrevious.all
if QPrevious.row(c).answered
}
QCurrent.set(payload)
A common pattern in trackers — let the respondent confirm or adjust their previous-period answers rather than retyping from scratch.
Anchored rows — paired and bipolarSlider
Two styles use per-row left.label / right.label to anchor each
row’s scale with descriptive endpoints:
style: paired— discrete scale (radios or buttons) flanked by the two labels. Use an odd-item scale when neutral is a meaningful position.style: bipolarSlider— continuous slider centred at neutral. Use an even-item scale so neutral isn’t a valid pick.
Both styles read the same per-row left.label / right.label props;
the difference is whether the respondent picks a discrete option or
slides a continuous control. The example below uses bipolarSlider;
swap to style: paired (and an odd-item scale) for the discrete
variant.
- qid: QPerception
type: gridSingle
text: Where does the brand sit on each dimension?
style: bipolarSlider
options:
1:
label: Quality
left.label: Low
right.label: High
2:
label: Price
left.label: Cheap
right.label: Expensive
3:
label: Brand
left.label: Generic
right.label: Distinctive
scale:
1: 1
2: 2
3: 3
4: 4
5: 5
6: 6
The respondent sees a slider per row anchored between the two labels; the stored value is the scale code under the thumb.
Export
gridSingle exports one column per row — each holds the chosen
scale code:
| What | Column |
|---|---|
| Row N’s chosen scale code | qidrN (e.g. QSatisfr1) — number |
Unanswered rows export as null. Masked rows (filtered by
options.from) also export as null. See
Tri-state projection.
See also
- gridMulti — multiple selections per row.
- gridNumber — numeric values per cell (rows × cols).
- single — one row only.
- Row & cell access —
.row(N)semantics. - Conditional & dynamic —
options.from,scale.from,if. - Collections — full method reference.