12. Modifying Table Appearance

In the previous chapters, you have learned how to modify a table view: in other words, how to determine which data will be displayed. Now you will see how you can control the data appearance: the graphical representation of the data on the screen.
The easiest way of modifying column appearance is through the Column Properties dialog displayed by the command of the same name from the table context menu. As mentioned before, this dialog always displays information about the active (or selected) column. Columns are selected by clicking on their headers while holding down the Ctrl key.

Change Column Title

Normally, the column title shows the column name (capitalized). However, the column name is sometimes not suitable for the title because for example the name contains underscores instead of spaces.
In our example, activate any element of the Price column, display the Column Properties dialog, and change the text in the Title field to Price excl. VAT. The change is immediately applied to the table. Now activate an element of the Album column (without closing the Column Properties dialog) to change the title to Album name in a similar way.
Moreover, if you unfold title details by clicking on the plus sign to the left of the Title label, you can uncheck the Fully displayed option so that the column width may be smaller than the title width (only a part of the title will be displayed).

Change Number Precision

Suppose you now wish to display two decimal places in the values of the Price excl. VAT column. Type number 2 in the Number precision field in the Column Properties dialog of this column. This change affects only the value appearance – it has no effect on the precision of the data stored in the table.

Spin Buttons

It would be nice to have spin buttons in the Stock column cells: in other words two small buttons to the right of the cell contents allowing you to increase and decrease the value in the cell by a mouse click. To achieve this, check the Spin buttons option in the Column Properties dialog (under the line editor properties below the Display heading).

Selecting Value from a List

As mentioned before, it would be more convenient to select the customer id (column c_id) of an order from a list of customer names rather than entering it manually as a number. To make this possible, take the following steps:
1.
Open the Column Properties window for the c_id column.
2.
Switch the column control from Line editor to Disp-folder.
3.
In the line below, press the Value selection button.
4.
Leave the Object name field set to cell_data (i.e. table cell data) and the Data reference field set to . (i.e. all data of the cell rather than a part thereof).
5.
In the Values section, set Selection type to from table (i.e. the selection will be determined by the contents of a defined table, usually located in the Data section).
6.
Leave the Object name of table data set to document (i.e. the source table of the selection is stored in the current document).
7.
Set the Reference of table data field to data.customers (i.e. the table of customers).
8.
Set the Value field to id. This setting determines the source table column that will provide data for the selection list.
9.
You cannot select a single column for the Title in selection setting because the customer’s name and address are stored in multiple columns. You therefore need to press the button at this attribute in order to specify the title in selection by means of an expression. Type the following expression:
last_name # " " # first_name # ", " # address # ", " # city
The # character is used to concatenate strings.
10.
The Displayed title setting determines how the currently selected value is displayed. If you leave this setting empty (only the . symbol), the displayed title will be identical to the title in selection (i.e. to the list of allowed values).

Color Highlighting of Albums out of Stock

Suppose you wish to display albums that are out of stock in red font. To do this, follow these steps:
1.
Open the Column Properties dialog for the Album column.
2.
Unfold the Other setting in the Functionality section under the Line editor properties.
3.
Uncheck the Non-formatted text option (so that the format of the displayed text can be modified).
4.
Unfold the Getter function setting, choose the Enki language, and specify the following expression:
if(row_data.stock==0)
add_cformat(val, rcf_fcolor(color(200, 0, 0)))
else
val
A document containing a modified table populated with data is stored in file Examples\Chapter 12.s-d.

Further Information

The following chapters of the Reference Guide contain detailed information on the discussed topic:
●
Enki Language – language used for the specification of expressions
●
Character Format FunctionsEnki language functions for character format manipulations
Next: Text Output