Formatting rules feature is one of the most important features of the template designer. It allows to create rules with specific criteria, and apply particular formatting to the corresponding elements when this criteria is met.
Formatting rules may be applied to any report element (like labels) or whole bands. You can apply rules to any element (for example, a band, or text control, or table row), by selecting it and finding list of rules in the properties panel, under Appearance - Formatting rules section, where you can create and edit formatting rules, as well as use check boxes to apply them to a selected element.
To view formatting rule properties, expand it using a triangle on the left:
Formatting rules allow may affect the following properties when applied to elements:
- Background color
- Border color
- Border dash style
- Borders
- Border width
- Font
- Foreground (text) color
- Text alignment
- Visibility
In the Condition property, you can specify an expression which will determine a condition when a rule should be applied or not. In the condition body, you can use data fields from a current context, where a rule is applied. In the example above, we're applying a rule for a root Invoice object (because Data Member property is empty). In the expression editor, you will find list of available fields, so it's not necessary to know/remember them. However, if you select something in the Data member property (for example, Invoice items), then this rule will use fields from this table, and it should be applied in a context where Invoice items table is used.
For example above, the condition is met when Tax1 field of the printed invoice is not empty. When this criteria is met, Visible property of the attached element is changed to Yes. If you will find SubBandTax1 band in the report and select it, you will see that its Visible property is set to No. This means that this band is not printed by default. In the Formatting rules property of this band this rule (ruleTax1) is applied. This allows to change Visible property of the SubBandTax1 band from No to Yes, when Tax1 field of an invoice being printed is not empty.
As you see, formatting rules are extensively used in invoice templates. For example, you may select invoice accent color in the application settings. Depending on the selected color, invoice elements will have different background and foreground colors. This has been achieved using formatting rules feature. Another example is possibility to hide template elements depending on values of the invoice being printed. Visibility change option allows to hide tax amounts if no any tax is selected in the invoice being printed. The same applies to invoice notes, discounts and any other elements.
It is not required from you to remember how to use IsNull function - it can be picked-up from the list in the condition editor: