Sample data and binding

Provide data and bind it into elements. Data and expressions in the DocStudio designer user guide.

Provide sample data

  1. Open the Data tab.
  2. Type or paste JSON, for example { "customer": { "name": "Ada" }, "items": [ { "name": "Pen", "qty": 2, "price": 3.5 } ] }.
  3. Press Apply. The canvas updates.

Any JSON works: no schema is needed. You can also use Load from file.

Paths

A path names a value. Separate keys with dots and write list positions in brackets.

Path Value in the example
customer.name Ada
items[0].qty 2

The Binding paths list in the Data tab shows every path with its type. Copy names from there to avoid typing mistakes.

Bind a value

In a text element, Add binding and pick a path. In other elements (barcode, QR code, repeater source, table source) use the expression editor and choose Data path.

The expression editor offers path suggestions that depend on where you are: inside a repeater or a table the paths start at the current row, and $root reaches the whole data.

Special names

Name Meaning
$root.x The root data, also from inside a repeater
$parent.x The enclosing level. Repeat for more levels
$index The position of the current item, starting at 0
$count How many items are in the list
$rows The list itself, used for totals in a table footer
$props.x A property passed to a reusable component

Fallbacks

Choose Use a fallback on a path to give a second path or fixed value that is used when the first is missing. A fallback replaces only a missing value, not null, empty text, 0 or false.

The sample is not saved with the template

Real documents get their data from the program that generates them. The sample only serves the preview. See Missing, null and wrong-type data.