A question was recently raised on the APEX Community forum about how to create a custom card report template in order to render a repeating group of Cards. Several of my recent projects have involved navigation via Cards, so this one got me thinking. And actually, I could totally see this being useful in a number of applications, so I thought I’d give it a try!

First of all, the results. Please keep in mind that this is a single report region with multiple groups.

House of Cards

You can also see it in action here.

Full disclaimer, most of the inspiration for this came from Jorge Rimblas, who has written some fantastic posts about the power of Classic Reports. Be sure to visit his blog from some great inspiration and how-tos!

In the meantime, here is the full break-down of how I built my ‘House of Cards’ Card Report Template.

The query

I am not here to teach you Oracle Analytic functions, and in fact, I had to dig through my notes from KScope18 to remember what exactly Jorge had done in one of his custom templates. And yay me, I found them.

This query yields these results:

Basically, the RN and TOTAL_ROWS columns tell me when a new repeating group starts (RN=1), and when it ends (RN = TOTAL_ROWS). I will use these conditions in my custom template.

New Custom Card Report Template

I started with a copy of the Report Template – Cards (Shared Components –> Templates –> Cards Report Template), which I then modified this way:

Modified Before and After Rows

I turned my template from a single Cards <UL>, to a <TABLE> containing ROWS of Cards. So my before and after rows open a <TABLE> tag rather than a <UL> tag

Before Rows:

After Rows:

Row Template 1

Basically, we are saying that this is the template to use every time we have a new repeating group (:RN=1), and it includes a row for #HEADER# (Our departments, in this example).

Row Template 2

Row Template 2

For these rows, we simply need to render the Card. It is neither the first record in the group, nor the last.

Row Template 3

Row Template 3

This is the template for the last record (Card) of a group. It is almost identical to Row Template 2, except it includes closing tags for the <UL> (list of cards), and closes the row.

I had hoped that by starting with a copy of the CARDS template, it would pick up the ‘Template Options’ I set using the #COMPONENT_CSS_CLASSES# substitution string, but that didn’t seem to work. So I’ve handled the customization with my ‘CARD_LIST_MODIFIERS’ column in my query.

In the example above, in order to render a 5 columns, raised fill, color animation list of cards, I used: ‘t-Cards–animColorFill t-Cards–animRaiseCard t-Cards u-colors t-Cards–displaySubtitle t-Cards–featured t-Cards–block force-fa-lg t-Cards–displayIcons t-Cards–cols t-Cards–5cols t-Cards–animColorFill’

You can refer to other classes using the table below, though.

Create Report Region on page, using new Custom Card Report Template

In the Attributes section of your query, select your new template. As mentioned, for some reason the Template Options did not seem to work for me, which is why I added my new custom column (CUSTOM_LIST_MODIFIERS) to both the template and query. If you have a better solution, please do let me know!

I think NEXT LEVEL AWESOMENESS for this guy would be to wrap a list of cards within… a parent list of Cards :-) So using this example, Card 1 would be ACCOUNTING, with the employees rendered as cards in the body. Card 2 would be RESEARCH, etc. But hey, we just got hit with 40cm of snow and I’d much rather go play. But if any of you peeps manage it, hope you’ll share!! Sharing is caring, amiright? And from what I know about the APEX Community, I have no doubt you will go above and beyond.

Speaking of which, my colleague Jaydip Bosamiya just published an awesome post about making your cards FLIP. I mean, I don’t even care what those babies really say, I just want the flippin’ cards ;-)

Happy APEXing, friends!