Skip to main content
This page has thin source coverage. Examples are derived from code configuration templates. Verify specific expression syntax and available context variables in the application.

Formatter Definition

PropertyTypeDefaultDescription
formattersobject{}Top-level section containing named formatter definitions. Each key is a formatter name referenced by columns.
formatters.<name>array[]Array of conditional rules for this formatter. Rules are evaluated in order.
formatters.<name>[].expressionstringNoneJavaScript expression that evaluates to true or false. When true, the associated style is applied to the cell.
formatters.<name>[].stylestringNoneName of a style defined in the styles section or a predefined style. Applied when the expression evaluates to true.

Formatter Evaluation Flow

diagram

Basic Formatter

A formatter that always applies a style (unconditional):
formatters:
  readonly:
    - expression: 'true'
      style: readOnlyStyle

styles:
  readOnlyStyle:
    backgroundColor: 'grey100'
Reference from a column:
columns:
  outlineNumber:
    title: "#"
    width: 80
    formatter: readonly
    isReadOnly: true

Multiple Rules

A formatter can contain multiple rules evaluated in order. Each matching rule applies its style.
formatters:
  boldTitle:
    - expression: 'true'
      style: boldTitleStyle

styles:
  boldTitleStyle:
    fontWeight: 600
The exact expression syntax and available context variables for conditional expressions depend on the runtime environment. Common patterns include 'true' for unconditional styling and JavaScript expressions accessing cell context.

Predefined Formatter Behavior

The readOnly formatter name has special significance. When a column references formatter: readOnly, the column is rendered as read-only with appropriate visual styling, replacing the deprecated isreadOnly column property.

Relationship Between Formatters, Styles, and Columns

Configuration SectionPurposeReferences
columns.<key>.formatterAssigns a formatter to a columnFormatter name
formatters.<name>Defines conditional rulesStyle name
styles.<name>Defines visual propertiesColor tokens

Complete YAML Example

columns:
  outlineNumber:
    title: "#"
    width: 80
    formatter: readonly
    isReadOnly: true
  title:
    title: Title
    width: 200
    hasFocus: true
    formatter: boldTitle
  systemRequirements.systemRequirement.title:
    title: System Requirement
    width: 180
    columnGroup: sysReq
  systemRequirements.systemRequirement.severity:
    title: Severity
    width: 100
    columnGroup: sysReq

columnGroups:
  sysReq:
    groupName: System Requirements
    groupStyle: darkblue
    headerStyle: blue
    collapseTo: systemRequirements.systemRequirement.title

formatters:
  readonly:
    - expression: 'true'
      style: readOnlyStyle
  boldTitle:
    - expression: 'true'
      style: boldTitleStyle

styles:
  readOnlyStyle:
    backgroundColor: 'grey100'
  boldTitleStyle:
    fontWeight: 600
The formatter value on a column must exactly match a key defined in the formatters section. A mismatched name results in no formatting being applied with no error message.

Source references: powersheet.yaml, whole_rtm.template.yaml
KB ArticlesSource Code
  • prod-powersheet-src/com.nextedy.powersheet.client/cypress/fixtures/configurations/whole_rtm.template.yaml
  • powersheet.yaml
  • prod-powersheet-src/com.nextedy.powersheet.client/src/modules/Powersheet/Powersheet.tsx
  • prod-powersheet-src/com.nextedy.powersheet.client/ltc-repo/packages/common/types/api/document.ts
  • prod-powersheet-src/com.nextedy.powersheet.client/cypress/fixtures/configurations/constraints_composing.template.yaml