Skip to main content
Skip table of contents

Conditional Formatting

Text formatting configurations can be applied conditionally to data bindings. A typical use case for this features is printing negative bound values in red, while printing positive numbers in the default text color. This can be achieved by a conditional text style with two predicate-formatting configuration pairs: one that colors the bound value red when the bound value is a negative number, and one that inherits text color by default. This article explains how you can create and apply such conditional text formatting styles.

Creating a Conditional Text Formatting Style

To create a conditional formatting style for a data binding, first select the data binding in the canvas, In the example below we want to create a formatting style that turns values of the bound field {{Net}} red if below zero. 

In the Properties panel on the right, tick Apply conditional formatting. This will allow you either to apply a conditional formatting style that has been created earlier, or define a new style.

The Create new style dialog allows you to give your style a name and then create one or more predicate-formatting configuration pairs. The predicate, or the condition is defined on the left, the formatting that should be applied when the condition is true, is defined on the right. You can create multiple condition-formatting pairs. The order in which they appear in the list is the order in which they are validated, top to bottom. Note that there is always a Default predicate at the bottom of the list which will contain the formatting configuration to be applied when none of the above conditions resolve to true.

You can add a condition by clicking the plus icon. This will bring up the condition dialog to define the condition. 


The condition will in this scenario apply to the value of the data binding. So, we can leave the field value to Bound value. If you define your condition in syntax mode, you can refer to the bound value with the parameter $this. Referring to the bound value, makes your conditional style flexibly reusable for other data bindings. But of course you can also specify a field in the condition.  

The condition is now added to the conditional formatting panel and you can now configure the style you wish to apply when the condition is true. To do so, highlight the condition on the left and set formatting preference for it on the right.


In the preview, the field to which we applied the style shows red text for negative values and black text for positive values.


Styles with Multiple Condition-Formatting Pairs

Conditional formatting can be more complex than the above-mentioned red if negative example. There can be multiple condition-formatting pairs in a single conditional style. For instance if you would like to emphasize numbers with a value above a certain threshold and print negative numbers in red, then you can do so by adding condition to the style and set corresponding formatting. Conditions are validated top to bottom. If a condition is true, the corresponding formatting will be applied, otherwise the next condition in the list will be checked and so on. At the bottom of the list there is a default condition. The formatting of the default condition will be applied when none of the above conditions are true. You can reorder conditions with the arrow controls and add conditions with the + control.

In the example below, negative bound values will be printed red, while values of 200 or more will be printed in bold face and with increased font size.

Applying a Conditional Text Formatting Style

To apply a conditional style that is already available in the template package, select the data binding either in design mode or data mapping mode and tick the Apply conditional formatting option  int he data section of the Properties panel. Select the style you wish to apply form the list of available styles.

Managing Conditional Text Formatting Styles 

In data mapping mode you can see a list of the available styles in the current template package. From this list you can also edit the styles. Be advised though that editing a conditional style may affect the formatting of data bindings elsewhere in the template. 

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.