Conditional Styles using Predicates

Summary

  • Most Format Column Style Conditions use a Predicate
  • This is evaluated by AdapTableQL - AdapTable's Query Language
  • A Format Column Condition can contain multiple Predicates if required
  • Conditions can use a Referenced Predicate - with different styled and evaluated Columns

Predicates are the most common use case for setting a Format Column Condition.

Standard Predicate Conditions

Predicates are easy to use to AdapTable and can be created visually at run-time through a wizard.

Predicates are ideal when the evaluation requires a single column or a single operation.

For example Price is Positive, Country is NonBlank, Amount is GreaterThan 20 etc.

Find Out More

See full explanations of how Predicates work in AdapTable in the AdapTableQL Predicates Guide

Format Column - Predicate Condition
Fork
  • This demo shows 3 Format Columns using Conditions with Predicates:
    • Issue Change Column displays green font where value is positive
    • Issue Change Column displays red font where value is negative
    • Any string column will show as Bold and Upper case if the value includes '.js'

Multiple Predicate Conditions

Prior to Version 14 only a single Predicate could be supplied for each Format Column Condition.

There is now no limit on how many Predicates can be provided in each AlertRule.

This allows for a more powerful and flexibile rules to be set.

Hint

It allows users to use Predicates in preference to more complicated (and sometimes off-putting) Expressions

Format Column - Multiple Predicate Conditions
Fork
  • This demo shows a Format Column Condition (Bold and Upper) with Multiple Predicates:
    • the Contains predicate with an input of "js"
    • the NotIn predicate with an input of "cyclejs"

Expand to see the Format Column Definition with Multiple Predicates

Referenced Predicate Conditions

Typically the Column defined in the Scope will be the one that is evaluated by the Predicate.

However this can be changed so there are separate Scopes for Column and Predicate.

This allows you, for example, to bold ColumnA values when the data in ColumnB meets the Rule in the Predicate.

Hint

  • This is useful if the column being evaluated is hidden or only accessible by scrolling, so a visible column is styled
  • Or if you want to style the first column in the Row and pin it

This is achieved by:

  • setting the Format Column Scope to be the Column which will be rendered
  • adding a ColumnId to the Predicate defined in the Format Column which will be the column evaluated

Note

This ColumnId property in the Predicate is optional; if not supplied, the Format Column Scope is used

Format Column - Referenced Predicate Conditions
Fork
  • This example shows how to use a Referenced Predicate:
    • the Predicate Scope is Github Watchers and the Rule is GreaterThan 3300
    • the Format Column Scope is Name (which is also pinned) and that Column displayed the Format Column Style
  • Note: This could also have been achieved by using an Expression of [github_watchers] > 3300 and the same Format Column Scope

Expand to see the Format Column Definition with a Referenced Predicate

Custom Predicate Conditions

Format Column Conditions can also use Custom Predicates.

These are bespoke Predicates defined by developers at design-time and then available for use in AdapTable.

Format Column: Custom Predicates
Fork
  • This demo creates 3 Custom Predicate Definitions and attaches a Format Column Condition to each:
    • Popular on Github Stars Column with Format of Bold Font on Blue Background
    • Vanilla on Language Column with Format of Yellow Font on Brown Background
    • Long String on Description Column (using Input of 40) with Format of Italics and Purple Border

Find Out More