Using Conditional Formatting With the DOM-API

In the Designer, numerous properties can be defined for different objects. Conditions can be used to use a property with a specific value only if the condition applies. This can be done in two ways in the Designer:

  • In the formula editor of the Designer a more or less complex formula can be constructed for the property - of course also combined and nested arbitrarily. However, knowledge of functions and syntax is already indispensable during input.

  • In order to minimize the contact with the formula editor in the Designer, so-called “conditional formatting” can be used, which can significantly simplify the settings for the properties and conditions for the user via dialog guidance. “Conditional formatting” can be used for objects that use the properties “Font”, “Frame”, “Background Color” or “Format”. Details can also be found in the Designer manual.

Using a simple example, the following shows how “Conditional Formatting” can be used within the framework of the DOM API. For a simple text column in a table, the property “Font” should be formatted depending on the displayed content of the used field:

// Add a new text column with the field "Article.No"
TableFieldText objTableFieldText = new TableFieldText(objTableLineData.Fields);
objTableFieldText.Contents = "Artikel.Nr";

// Get object for "Conditional Formatting"
ConditionalFormatterItem objConditionalFormatterItem = 
	new ConditionalFormatterItem(objTableFieldText.ConditionalFormatter);

// Define "Font" formatting
objConditionalFormatterItem.Modifiers.Font.Bold = "True";
objConditionalFormatterItem.Modifiers.Font.Color = "LL.Color.Red";
objConditionalFormatterItem.Modifiers.Font.Italic = "True";
objConditionalFormatterItem.Modifiers.Font.Strikeout = "False";
objConditionalFormatterItem.Modifiers.Font.Underline = "True";

// Define condition for formatting
objConditionalFormatterItem.Condition = "Contains(LL.CurrentValue,\"EXP\",1)";

Now the font for the table column “Article.No” is colored red, made bold and underlined if the article number contains the text “EXP”:

© combit GmbH