Using Cell Variants to Dynamically Assign Search Helps in a Table
The TableStandardCell UI element can be used to create table cell variants so that a different table cell is displayed in a column for each row depending upon a dynamic condition. This ability is particularly useful for displaying a different search help in a table cell according to a user selection in another field.
The user may enter account assignment using any combination of three cost object types, Cost Center, Internal Order or WBS Element, and you need to provide an appropriate search help in the cost object field according to the selected cost object type.
1.0 Define a Context Node
Define a context node ACCOUNT_ASSIGNMENT with Cardinality 1..n and Selection 0..1. Add the following five attributes.
|Attribute Name||Attribute Description||Suggested Type Assignment||Dictionary Search Help|
|KONTY||Cost Object Type||
|*In this example, we have used a custom Type Assignment, ZKONTY, whose underlying domain contains a fixed value set for use by the table cell’s DropDownByKey, but you may use any appropriate Type Assignment, e.g., KONTY.|
2.0 Create a Table UI Element
Create in the view a Table with the following UI elements.
2.1 Create TableColumn TABLE_KONTY, and insert into the column a cell editor, TABLE_KONTY_EDITOR, of type DropDownByKey. Bind its selectedKey property to context attribute ACCOUNT_ASSIGNMENT.KONTY.
2.2 Create TableColumn TABLE_COST_OBJECT, and assign its selectedCellVariant property to context attribute ACCOUNT_ASSIGNMENT.KONTY. Insert into the column three TableStandardCell elements, one for each of the cost object types Cost Center, Internal Order and WBS Element. For each TableStandardCell, assign its variantKey property according to the KONTY value that corresponds to the cost object type. For example,
|TableStandardCell ID||Cost Object Type||Corresponding KONTY Value||TableStandardCell variantKey|
2.3 Insert into each TableStandardCell an InputField editor. Bind the value property of each InputField to the corresponding attribute of context node ACCOUNT_ASSIGNMENT.
|TableStandardCell Editor ID||Value Property Binding|
2.4 Create TableColumn TABLE_PROZS, and insert into the column a cell editor, TABLE_PROZS_EDITOR, of type InputField. Bind its value property to context attribute ACCOUNT_ASSIGNMENT.PROZS.
3.0 Trigger Cell Variant Assignment
The final step is to create an action that will assign the corresponding cell variant when the user selects a cost object type from the DropDownByKey field. In the TABLE_KONTY_EDITOR DropDownByKey element, create a new action, ASSIGN_CELL_VARIANT, for the onSelect event. The method ONACTIONASSIGN_CELL_VARIANT may be left blank, however it is necessary to trigger an action in order for the cost object type selected by the user to prompt assignment of the appropriate TableStandardCell variant.
Now when the user selects a cost object type from the DropDownByKey field, the corresponding cell variant is displayed in the Cost Object column along with the appropriate search help for each cost object type.