K2

Using K2 SmartForm Expressions and Conditional Styles Simultaneously

We have previously talked about the different uses of K2 SmartForms expressions, but today we will be using these expressions in combination with conditional styling. The example we will be using is to display a progress percentage together with a progress colour for grouped activities.

k2 smartforms expressions

K2 SmartForms Expressions & Conditional Styles – 1

When you use expressions in a K2 ListView that reference a K2 SmartObject property, it is best to not bind the column to any property. Essentially you will do the binding in the expression itself. When you select the column and navigate to the body properties you can see an expression has been selected and conditional styling set up.

K2 SmartForms Expressions & Conditional Styles - 2

K2 SmartForms Expressions & Conditional Styles – 2

First we will look at the conditional styling. For each conditional style you add you have to specify a condition as well as a style.

K2 SmartForms Expressions & Conditional Styles - 3

K2 SmartForms Expressions & Conditional Styles – 3

When you specify the style you have access to the exact same formatting options as you do when normally specifying the style of any K2 SmartForms control. For this example we changed the background colour (green, amber and red respectively) and font colour (white).

K2 SmartForms Expressions & Conditional Styles - 4

K2 SmartForms Expressions & Conditional Styles – 4

When you set up the condition associated with the style it works almost like a normal K2 expression, just limited to a basic if-statement. You have access to the SmartObject on your current K2 View (or all view on the current K2 SmartForm) and you can also use other expressions..

K2 SmartForms Expressions & Conditional Styles - 5

K2 SmartForms Expressions & Conditional Styles – 5

When you set up the expression you have access to the SmartObject on your current K2 View (or all view on the current K2 SmartForm), other expressions as well as a list of operators. At the bottom of the screen you will see a preview of your expression in it’s current form.

K2 SmartForms Expressions & Conditional Styles - 6

K2 SmartForms Expressions & Conditional Styles – 6

You may also like

2 comments

  • Liam Phillips September 25, 2015   Reply →

    Arno
    How did you get the Correct Symbol into the expression?

    Liam

  • Arno van Rooyen September 26, 2015   Reply →

    Just copy it from a rich text control into the SmartForm expression designer and it works.

Leave a comment

PODCAST  |  Why you need to establish a K2 Center of Excellence today

Interview with Arno van Rooyen, CEO, Velocity