Template columns
This is where things get complicated. This is an advanced system
designed for IT professionals who have a knowledge of databases and HTML and
want to fully customise the display of information in a column. If you
don't fit into this category then our support department is happy to help
you. Email what you are trying to achieve to
support@repeatsoftware.com
and they will assist you getting the your template set up. Support is
free of charge.
Template columns allow you to display fields from your database records/rows
in a customised format. If you want to display field/column
information then your fields must be included in the
SQL
statement used to collect your data. The data grid will
automatically try to display all of the fields you listed in your SELECT
statement and you will need to set the visibility to False for each of the
columns you don't want displayed in the grid.
Getting started
To display fields in your template, you use <FieldName> where you want the
field information to be displayed. Let's start with an example.
If we had a database table called Products as follows:
ProductCode |
Description |
Stock |
Price |
|
|
|
|
Prod1 |
Widget type 1 |
15 |
25.00 |
Prod2 |
Widget type 2 |
0 |
50.00 |
So in our template field we may want to create a simple sentence on each
product in our template field such as:
We have 15 units left of Widget type 1
So our template would need to be:
We have <Stock> units left of <Description>
So in the above template we are using <Stock> to insert the value of
the Stock field of the current line and <Description> for the description
field. We have added a Preview below to show how that would display:
ProductCode |
Description |
Stock |
Price |
Preview |
|
|
|
|
|
Prod1 |
Widget type 1 |
15 |
25.00 |
We have 15 units left of Widget type 1 |
Prod2 |
Widget type 2 |
0 |
50.00 |
We have 0 units left of Widget type 2 |
We may want to extend this and include a price in our sentence along the
lines of:
We have 15 units left of Widget type 1 and the price is $25.00
If we update our template to:
We have <Stock> units left of <Description> and the price is <Price>
Then we don't get exactly what we want:
We have 15 units left of Widget type 1 and the price is 25
The problem is that instead of getting $25.00 we get 25. What we
can do is to include a FormatString in the field name.
So in the case we would add a format string of {0:$#,##0.00} to our <Price>
field like below:
We have <Stock> units left of <Description> and the price is
<Price{0:$#,##0.00}>
Which would then give us the text with the price in the required format:
We have 15 units left of Widget type 1 and the price is $25.00
The same type of inline formatting can also be done with date, text and
boolean fields.
Numeric format strings
For numbers we use the standard Microsoft FormatStrings. See
the following Microsoft page:
https://msdn.microsoft.com/en-us/library/0c899ak8(v=vs.110).aspx
Example:
<PriceFieldName{0:$#,##0.00}>
Display price in the format '$45.23
'.
With numbers you can also put IF statements into the format codes. You
can specify what to display for positive, zero and negative numbers.
See this entry:
https://msdn.microsoft.com/en-us/library/0c899ak8(v=vs.110).aspx#SectionSeparator
Date/time format strings
For numbers we use the standard Microsoft FormatStrings. See
the following Microsoft page:
https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx
Example:
<DateFieldName{HH:mm}>
Display just the time part of the date/time in 24 hour format sicj as 15:42.
Example:
<DateFieldName{dd MMMM yyyy}>
Display the date like '23 February 2015'.
Date strings can also have an optional culture code. The following
applies as Swedish
culture code, i.e.
{sv-SE}, to a date field called
StartDate.
<StartDate{dd MMMM yyyy}{sv-SE}>
On an English language version of Windows then the format code {dd MMMM
yyyy} would produce as result like '23 February 2015'. With the
Swedish culture code applied you get '23 februari 2015' instead.
Text fields format strings
These are non-standard format codes but the names are commonly used in
programming languages:
Format code |
Description |
|
|
{lcase} |
Convert field text to all lower case |
{ucase} |
Convert field text to upper case |
{scase} |
Convert to sentence case. |
{ufcase} |
Changes first letter of each word to upper case and the rest in
lower case |
For example, using with a field named 'CompanyName' and you wanted all the
names in upper case, you would insert:
<CompanyName{ucase}>
Text fields that actually contain date/time or numeric information
When using XML and CSV files then usually all of the columns will be seen by
Repeat Signage as being text. Dates in XML files are often in the
format "2015-02-13T09:00:00". You can still use the date/time and
number format strings. What Repeat Signage does it to detect the data
type and then formats.
For example, a database field called Creation from an XML file could
contain:
2015-02-13T09:00:00
and we can display this with:
<Creation{dd MMMM yyyy}>
and Repeat Signage will realise that this is a date and display this as:
13 February 2015
HTML text formatting support
You can use basic HTML tags to layout your fields as you would like to see
them. This includes using the HTML <BR> tag for line breaks and
<strong></strong> tags for making text bold, etc. We don't support all
HTML tags. See
Repeat
Signage Basic HTML for a list of supported tags. In our above
products example, we used the template:
We have <Stock> units left of <Description> and the price is
<Price{0:$#,##0.00}>
to give us:
We have 15 units left of Widget type 1 and the price is $25.00
We could add in some HTML tags:
We have <Stock> units left of <Description>.<BR> <strong>The price is
<Price{0:$#,##0.00}></strong>
The <BR> tab adds a line break to move the text after the <BR> onto a second
line. The text between the <strong> and </strong> tags makes all that
text bold. So the output would be:
We have 15 units left of Widget type 1.
The price is $25.00
IMPORTANT NOTE - You have to set the 'Display as' box to the "BASIC HTML"
option to tell Repeat Signage you want to format as HTML.
Boolean (True/False) fields
Boolean fields are True or False. Some databases also allow Null
values which is when a value hasn't been specified. Again, you can use
these non-standard format strings but based on the Microsoft format for
numeric strings:
Format code |
Description |
|
|
{Yes;No} |
Display 'Yes' if boolean value is True and 'No' if boolean value
False. |
{Yes;No;Unknown} |
Display 'Yes' if boolean value is True and 'No' if boolean value
False. Also display 'Unknown' if the field is Null |
You can put any text in this format as long as you don't use the ; symbol in
your text. So if you had a field called 'DrivingLicence' in an
employee database and wanted to display 'Has a driving licence' or 'No
licence' then the format code would be {Has a driving licence;No
licence}, so you would put the complete field in the template as:
<DrivingLicence{Has a driving licence;No licence}>
NOTE - You can use HTML tags in this as well. However, you have to
encode the < and > symbols in HTML encoding. So '<' becomes '<' and
'>' becomes '>'. So to bolden the 'Has a driving licence' in the
above example, we would surround with <strong> and </strong> tags, with the
< and > symbols encoded. The new field would be:
<DrivingLicence{<strong>Has a driving licence</strong>;No
licence}>
which would bolden all True values but leave the False values in regular
text.
Standard column options on this screen
In addition to the above options, then these standard options are available:
Column title - The text to display in the column header.
Visible - Whether the column is visible. You can set this to
false to completely hide a column that is no longer needed. A better
option if dealing with a lot of database records is to remove this from the
field list in the
SQL statement used to collect your
database information.
Column header align - Choose if your column header is left, centre
or right aligned.
Column data align - Choose the alignment of the cells in this
column.
Column width - The column's width in pixels. If you have
chosen 'Auto column width' on the data grid settings tab, then you cannot
change this.
Display text as - The choices are TEXT or BASIC HTML. Text is just
straight plain text. With the TEXT option the font, font size, colour, etc, are set on
the data grid options tabs. The
Basic HTML option allows you to use
formatted text so you can mix text formatting. For example: "This
is a
big dog" where the word "big" is italic and the
word "dog" is in bold. See
Repeat
Signage Basic HTML for more info.