The main purpose of a grid is to display information from a table. Grids show a number of columns which represent fields, but it is possible to show more than one field in a column and add HTML tag formatting.
In the below image, both the Contact column and the Phone & Email column show three fields. This is done with the use of Expressions.
Customizing a Grid
In this example, we will customize the Contact List screen to permanently show the address in a column. The address of a customer is made up of a number of fields.
In order to create or edit a column in a grid, you will first need to customize the screen.
1. While on the Contacts List screen, click the caron symbol ( ⌄ ) by the Contacts header and then select Customize Screen.
2. You will be prompted to view the screen as read-only, or to Create a copy. You want to create a copy, so select that.
3. Find the ContactsGrid and click the down arrow (▼) on the control. Select Columns from the drop down menu.
4. You will be presented with a list of columns and you will see Billing Address columns, but don't select those. Instead, scroll to the bottom and click ⊕ Add another column.
5. Under Add New Column, you will find a Specialty column called Expression, which you can click to add more than one field into columns.
6. The screen to configure the expression comes up, and is similar to configuring regular columns. I changed the caption to Billing Address so that the column will have a proper title in the grid. To create an expression, select the Create Expression link beside Expression Builder.
Using the Expression Builder
When you first open up a new expression, it will be blank as shown in the below image.
Clicking ⊕ Add another item will allow you to add fields and text to the column. You can add as many items as you want to create the your column. An expressions is composed of either:
- Custom text
- A value from a field
In the below example, I've created a simple expression using a combination of text and fields. The text only holds HTML TAGS to create new lines and bold formatting.
- Starts with: The first item in this expression is the BillAddressAddr1 field.
<br/>tag is a new line tag so the next field will start on the next line.
- BillAddressCity: The city of the billing address.
,: Although hard to see, this is a comma followed by a space. This puts a comma after the city. Since there is no <br/> tag, the next field continues on the same line.
- BillAddressState: The state of the billing address.
, <strong>: Again we have a comma, but this time we have add the start tag to indicate the next field will be bolded.
- BillAddressCountry: The country of the billing address.
</strong><br/>: This ends the bold tag, so text and fields after this will not be bolded. Also, a new line is added again.
- BillAddressPostalCode: The Zip code of the billing address.
Once you close this expression and go back to the grid, it will look like the below image (I've removed a few columns for easier viewing):
To edit the expression column, find and select the column you wish to edit in the column properties, and select Create Expression again.