Expression

Expression

image

Description

The ExpressionElementWdg allows you to use the TACTIC expression language to determine the value displayed in the table cell. The expression is caclulated from a starting sobject which represents the sobject in the particular row in the table. The expression is evaluated for each sobject on every row. When an expression is evaluated, the value is added to a dynamic attribute of the sobject and can be used in future expressions in this widget. Please refer to the expression language reference for more information on the expression language.

Info

Name

ExpressionElementWdg

Class

tactic.ui.table.ExpressionElementWdg

Category

Common Columns

Supported Interfaces

TableLayoutWdg

TACTIC Version Support

2.5.0

Required database columns

depends on expression

Implementation

Display the total cost of an item by multiplying the total_number column with the unit_cost column When an expression is evaluated by the ExpressionElementWdg, a new attribute with the name of the element is dynamically added to the sobject (in this cost) which can be used in the "bottom" directive.

<element name='cost'>
  <display class='tactic.ui.table.ExpressionElementWdg'>
    <expression>@GET(.total_number) * @GET(.unit_cost)</expression>
    <bottom>@SUM(.cost)</bottom>
  </display>
</element>

Options

expression Expression to evaluate the widget

display_format

Display format string like DATETIME, DATE, -$1,234 applicable for various Formatted Element can be used here.

inline_styles

Styles to add to the DIV generated that contains the result of the expression

return

single

list - Determines what the expression return type should be

bottom

Expression to calculate the bottom row of the table

group_bottom

Expression to calculate the group bottom row of the table

mode

value

boolean

check

icon - Display mode for this widget

expression_mode

default

absolute - If absolute mode is selected, it does not relate to the current SObject

calc_mode

fast

slow - fast uses new calculation mode. Only @SUM, @COUNT, @SOBJECT and @GET are current supported

enable_eval_listener

Currently javascript expression evaluation is not fully baked, so only use the client side evaluation listener when needed and NOT by default

icon_expr

Expression to evaluate which icon to use when mode = 'icon'

order_by

provide a simple string to order by e.g. code or by an attribute in a related sType in the same database, e.g. prod/sequence.dsecription

group_by

true

false - Turn on group by in context menu if set to true

group_by_time

true

false - Turn on group by time options in context menu if set to true

justify

default

left

right

Examples

Display the number of tasks for a given sobject and then display the total number at the bottom.

<element name='num_tasks'>
  <display class='tactic.ui.table.ExpressionElementWdg'>
    <expression>@COUNT(sthpw/task)</expression>
    <bottom>@SUM(.num_tasks)</bottom>
  </display>
</element>

Mode "boolean" displays a green dot for every sobject that has an expression that evalutes to True. In this case, a green dot is display on every row where the number of tasks is greater than zero.

<element name='has_tasks'>
  <display class='tactic.ui.table.ExpressionElementWdg'>
    <expression>@COUNT(sthpw/task) > 0</expression>
    <mode>boolean</mode>
  </display>
</element>

Another example of a mode which displays a checkbox instead of red/green dots. The checkbox appears for any result greater than zero

<element name='has_tasks'>
  <display class='tactic.ui.table.ExpressionElementWdg'>
    <expression>@COUNT(sthpw/task) > 0</expression>
    <mode>check</mode>
  </display>
</element>

The expression language has the ability to get values from other related tables. The following example illustrates an expression to find the description of the parent sequence of a shot.

<element name='sequence_description'>
  <display class='tactic.ui.table.ExpressionElementWdg'>
    <expression>@GET(prod/sequence.description)</expression>
  </display>
</element>

The expression language has the ability to get values from other related tables and format it using the DATETIME project setting which can be customized per project

<element name='task_due_date'>
  <display class='tactic.ui.table.ExpressionElementWdg'>
    <expression>@GET(sthpw/task.bid_end_date)</expression>
    <display_format>DATETIME</display_format>
  </display>
</element>

Ultimately, the ExpressionElementWdg can make use of any expression in the TACTIC Expression Lanaguage.

When using mode = 'icon', it is possible to set up an expression using icon_expr to determine what that icon should be. A special variable $VALUE is used to determine the value of the expressions

<element name="is_synced" title='Synced' edit='false'>
  <display class='tactic.ui.table.ExpressionElementWdg'>
    <expression>@GET(.is_synced) == True</expression>
    <mode>icon</mode>
    <icon_expr>@IF( '$VALUE' == True, 'CHECK', 'CROSS' )</icon_expr>
  </display>
</element>