One of the elements of this dashboard was a group of four infocards.
These cards display the key values for a country on a certain subject. Apart from the text the cards differ in color and the icon used.
These cards are created using a named report template. This is a special kind of report template. Using a normal report template the query columns and rows map to the columns and rows in a HTML table. A named report template consists of a HTML template in which the query columns are referenced by name. For the infocards the query and template below are combined:
select 'Population' title , population data , 'Number of inhabitants' text , 'fa-users' as icon_class , 'db2_red' as container_class from cnt
Row Template 1 within the Report Template:
The substitution strings in the template are replaced with the corresponding values from the query.
As you can see the column values can also be used to define CSS classes as in the enclosing DIV element. The value of the column container_class defines the name of the class to applied. This class defines the color of the card. The class icon_class defines the Font Awesome icon to be used.
The cards are styled with the following CSS:
The color of the card can be defined by selecting the db2_color class as container_class in the query.
The icon is positioned absolute relative to the card with the class db2_icon_container. Space is created for the icon container by defining left:80px; for the main DIV containing the text.
The rest is quite straight forward CSS styling.
You can create your own Named Report Template:
- navigate to Shared Components > Templates
- press Create
- chose Report
- create the template From Scratch
- enter the name for your template and check Named Column (row template)
- then enter the HTML for the template
Named Report Templates provides us developers with more freedom to style the output. The downside is that the templates are more specific and less widely applicable.
Happy Apexing