Friday, 28 April 2017

Displaying info cards using an Oracle Apex named report template

For the Apex Dashboard Competition of the DOAG in 2016 I created a Apex dashboard. You can read about it in this post
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:

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_colorclass 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.

Hi Dick,Thanks for taking time and explaining this in detail.This was a perfect blog which helped me get through the solution.Really appreciate your help and step by step process. I was able to create the cards from scratch and format as expected.

Everything is working perfect now and thanks goes to you. Your help is really appreciated. Thank you!