Table Style Rules
When using Tables in reports, it is useful to apply styles to the data so they stand out apart from the rest of the data. Rules can be applied at the Row Level or at the Column level. These rules override the general or default table settings applied in the table tool based on conditions set for each rule.
If using table styles to customize colors, see Colors.
Access the Styling Rules Editor
There are two types of rules and there is a control button for each rule type.
Column Rules: are applied to an individual field in the table. When a column rule is applied, the field the rule is applied appears in bold in the Configuration window. Column Rules are accessed in the Per Column Configuration of the Table Properties window. To apply a Column Rule:
- Click the field name to apply the rule to.
- Click the Create/Edit button to set the parameters of the rule.
Row Rules: are applied to the entire row of data in a table (such as highlighting a Total row). Row Rules are accessed from the bottom of the Table Properties Window. To apply a Row Rule:
- Click the Create/Edit Row Rule button to set the parameters of the rule.
To apply a Rule to the Table, the button may read one of two ways:
- Create Rule: If no rule is already applied, the button will read Create Rule. Clicking this button will create a new rule to apply to the table.
- Edit Rule: When a rule already exists, the button will read Edit Rule. Clicking this button will expose the rule editor so that existing rules can be edited and new rules can be created.
Configure the Styling Rules Editor
Rule Names: Rules that are currently being applied either per column or per row appear in the top section of the editor. To edit an existing rule, highlight the rule to edit. Options include:
- New: Creates a new rule.
- Delete: Deletes the selected rule.
- Up/Down: Reorders the selected rule.
- Rule Name: User can type in this section to set a more descriptive name for the rule.
- Rule Conditions: Choose one of 3 modes to apply the Rule condition. Choices include:
- Always: Always apply the rule in all conditions. When applying this mode to a column rule, the user can choose what to apply the rule to Data Only, Header Only or to the Header and Data.
- When: Applies the rule only when the specified condition is met. Use the drop downs to specify the condition. This condition is usually a straightforward one not requiring a complex formula.
- Formula: Applies the rule only when the specified condition is met. Clicking the ... button will expose the formula editor enabling the user to construct a more detailed condition. This condition usually compares two or more variables.
When specifying a Row Rule, an additional checkbox displays to allow the user to specify whether that rule should override an existing Column Rule. Rule Hierarchy is discussed below.
Styles: The Styles section is where the user applies the styling options that are applied to the data if the condition specified above is met. Options include:
- Font: Changes the font type when the condition is met. All installed fonts on the machine are displayed. Click the drop down to select the desired font type. Bold and Italics can also be applied by clicking their respective buttons.
- Font Size: Changes the font size when the condition is met. Use the up/down controls to increase/decrease the font size.
- Justification: Changes the position of how the data fills the cell when the condition is met. Options include: Left, Right or Center.
- Text Color: Changes the color of the text when the condition is met. Click the... to expose the color picker.
- Background Color: Changes the cells' background color when the condition is met. Click the... to expose the color picker.
- Prefix: Prepends a prefix when the condition is met. Option is only available for Column Rules when a Numeric field is chosen to apply the rule to.
- Suffix: Appends a suffix when the condition is met. Option is only available for Column Rules when a Numeric field is chosen to apply the rule to.
- Decimal Places: Displays the text with the specified amount of decimal places when the condition is met. Option is only available for Column Rules when a Numeric field is chosen to apply the rule to.
Formula Styles: Advanced option - When the basic style overrides are insufficient, users can create their own style overrides, by writing a formula which constructs CSS-like style text. This formula is computed individually for each cell to which it applies, and can be very powerful. Use of this requires a solid understanding of CSS styles and some knowledge of PCXML and Composer.
Some Common PCXML properties to use within formulas:
- background-color: the background color of a table cell or row.
- decimal-places: the amount of numbers that will appear after a decimal point for a numeric value.
- postfix: text that will directly follow a value.
- prefix: text that precedes a value.
- background-image: sets an image as the background
- color: foreground color of the object.
- border: defines the borders around an element.
- padding: the space between the element border and the element content.
- font-weight: sets how thick or thin characters in text should be displayed.
- font-style: sets the style of a font.
- text-align: aligns the text in an element.
- white-space: declares how whitespace inside the element is handled: the 'normal' way (where whitespace is collapsed), as 'pre' (which behaves like the 'PRE' element in HTML) or as 'nowrap' (where wrapping is done only through BR elements).
- text-decoration: the decoration of the text such as overline, underline, line-through, none, or blink.
Rule Hierarchy
Using rules effectively requires understanding which rules comes first, and which ones override other ones. When two rules intend to change different styles (one changing a font, and the other changing the font size, for example), it doesn't matter which one executes first. But when two rules both intend to change the same style, only one them will win. Rules are executed in the following order, with later rules overriding earlier rules.
- Default Table Settings have the lowest priority.
- Per-Column Configurations
- Row rule with only basic (non-formula) styles
- Column rule with only basic styles
- Row rule with only basic styles with the override checkbox selected
- Row rule with formula styles
- Column rule with formula styles
- Row rule with formula styles with the override checkbox selected
Here is another way to look at this.
- Formula styles always take precedence over non-formula (basic) styles.
- Column rules usually take precedence over row rules, unless the row rule explicitly has its "override column rules" checkbox checked.
- Rules take precedence over the per-column and default table settings.
- Multiple rules of a given type (row or column, basic or formula) execute in the order they are listed in the rule editor.