AG Studio Launch Week 🚀🚀🚀 28 Sep - 2 Oct 2026 🚀🚀🚀 Join now

JavaScript Embedded AnalyticsEditable Fields

Version 3.0.0

The editable property on a field definition controls which of its properties a user may change. Fields a user creates themselves are always fully editable.

For the end-user view of this, see Calculations and Using Data in the User Guide.

Editing Fields Copy Link

Fields are fully editable by default. Use the editable property on a field definition to lock a field down or to restrict which properties the user can change:

const fields: AgFieldDefinition[] = [
    { id: 'country', format: 'textFormat' },
    { id: 'sport', format: 'textFormat', editable: false },
    { id: 'gold', format: 'integerFormat', editable: ['name', 'formatOptions'] },
    { id: 'silver', format: 'integerFormat', editable: ['name'] },
];

Pass false to make the field read-only, or an array of AgFieldEditableKey values to allow a subset:

KeyWhat the user can edit
nameThe display name shown wherever the field appears.
descriptionThe description shown in the Field Panel.
formatOptionsFormatting options for the field's format type (see Formatting).

editable is available on field definitions, expression fields, and Measures. Note fields the user creates in the UI are always fully editable.

In the example below, select any field in the Data Panel to switch the Edit Panel to its field view. Each field is configured differently:

  • Country: fully editable (default).
  • Sport: read-only (editable: false).
  • Gold: name and format options editable (editable: ['name', 'formatOptions']).
  • Silver: name only (editable: ['name']).
  • Bronze: read-only (editable: false).

Editing Expressions Copy Link

The Expression input is only shown for Calculated Columns and Measures the user created themselves. The expression syntax is case-insensitive throughout: function names, booleans, and the table and field names in a reference all match regardless of case. The input offers autocomplete for functions and fields, bracket matching, and inline syntax errors. An invalid expression is still saved, but the field produces no values until it parses.

DescriptionSyntax
Field referencesMedals[Gold], [Total Medals], 'Completed Orders'[Date]
Strings"string" (double quotes only)
Numbers123, 1.23, 1e3
BooleansTRUE, FALSE
Arithmetic operators+, -, *, /, ^
Brackets3 * (2 + 1)
Comparison operators>, >=, <, <=, =, == (alias for =), <> (not equal)
Boolean operatorsNOT x, &&, ||
String concatenationa & b
Function callsADD(a, b)
Comments-- Single Line, // Single Line, /* Multi Line */

For a list of functions, see Function Expressions.

The Format input should be set to a value that relates the expression. For example, if the expression returns a number, the Format could be set to Integer or Decimal, but not Text. Widgets using fields with such mismatches may fail to display data.

Schema State Copy Link

User edits and user-created fields are both persisted in the schema slice of the report state, as an AgSchemaState. Save and restore it with the rest of your report state - see State for the full state model.

const schema = {
    fields: {
        'medals.gold': {
            name: 'Golds'
        },
        'expression-1': {
            name: 'Total Medals',
            expression: '[medals.gold] + [medals.silver] + [medals.bronze]',
        },
    },
    expressions: [
        {
            isMeasure: false,
            id: 'expression-1',
            tableId: 'medals',
            format: 'integerFormat'
        }
    ],
};

fields contains per-field overrides for both developer and user created fields. It is keyed by the ID of each field. Each entry may contain:

  • name
  • description
  • format - a format string (only available for built-in formats, see Formatting)
  • expression - only for user created expressions

Serialised expressions encode field references using their ID rather than their name. E.g. Medals[Gold] is serialized as [medals.gold]. The user will always see the former.

expressions declares the fields the user created. Each entry has:

  • id (required) - a unique ID (auto-generated when created via the UI)
  • tableId (required) - the ID of the data source the field was added to.
  • isMeasure (required) - true for a Measure, false for a Calculated Column.
  • format - the format type, defaulting to integerFormat.