Using Templates with Scriptcase (Custom Grid/Reports)

ScriptCase can create Custom Grids/Reports (billets, invoices, business cards, etc). You can create a HTML file using your own layout, but following some rules.

It should be a HTML file. We can stipulate where Scriptcase fields will be displayed on the HTML file using “curly brackets” {variable}. As you can see below:

HTML Code

<table border="0" cellspacing="0" cellpadding="0">
   <tr>
        <td width="247" height="96" align="left" valign="center">
        <font face="verdana" style="font-size:11px">
        <b>{Name}</b><br>{Address}<br>{City}- {State}<br>
        {ZIP}
        </font>
        </td>
   </tr>
</table>

Running the HTML code above.
{Name}
{Address}
{City}-{State}
{ZIP}

In the Template we can define a Loop feature using a flag (see in red):

C?digo HTML

<table border="0" cellspacing="0" cellpadding="0">
   <tr>
     <!-- BEGIN bl2 -->
        <td width="247" height="96" align="left" valign="center">
        <font face="verdana" style="font-size:11px">
        <b>{Name}</b><br>{Address}<br>{City}- {State}<br>
        {ZIP}
        </font>
        </td>
     <!-- END bl2 -->
   </tr>
</table>

The red parts define where the loop will start and finish. The iterations amount is defined by “Columns per Page” of the Grid.

eg: If “Columns per Page” is 3 so it will display the following result.

HTML code

<table border="0" cellspacing="0" cellpadding="0">
   <tr>
        <td width="247" height="96" align="left" valign="center">
        <font face="verdana" style="font-size:11px">
        <b>{Name}</b><br>{Address}<br>{City}- {State}<br>
        {ZIP}
        </font>
        </td>
        <td width="247" height="96" align="left" valign="center">
        <font face="verdana" style="font-size:11px">
        <b>{Name}</b><br>{Address}<br>{City}- {State}<br>
        {ZIP}
        </font>
        </td>
        <td width="247" height="96" align="left" valign="center">
        <font face="verdana" style="font-size:11px">
        <b>{Name}</b><br>{Address}<br>{City}- {State}<br>
        {ZIP}
        </font>
        </td>
   </tr>
</table>

Running the HTML Code above
[table][tr][td]{Name}
{Address}
{City}-{State}
{ZIP}[/td][td]{Name}
{Address}
{City}-{State}
{ZIP}[/td][td]{Name}
{Address}
{City}-{State}
{ZIP}[/td][/tr][/table]

After done the “.html” file we should include it in Scriptcase accessing “Tools>>Layout>>Templates”.

Select “Free Format” and Upload the file.

Then Create a new Grid application and select “User Defined” Option in “Orienation” setting.

Access “Grid>>Layout>>Settings” and select the “Body Template”.

Now we should associate the template variables with the Grid fields. (Grid>>Select Fields)

Format the fields and Run. It is done.

V?tor Jamil

Re: Using Templates with Scriptcase (Custom Grid/Reports)

Dear Vitor,

thank you for this good example!
I would like to have an template where I check the user group of the currently loged in user. Depending on that group I would like to hide certain fields. Is this possible with templates?

Thank you!

Best regards
Arno

Re: Using Templates with Scriptcase (Custom Grid/Reports)

Yes, it is possible using onInit event to check the group and hidding the fields with “sc_field_display” macro.

Re: Using Templates with Scriptcase (Custom Grid/Reports)

So how come this type of template level customization isn’t in place for applications like control, form, etc.?

Many times you can’t do anything very easy in SC around custom layout using the SC IDE, and simple things for layout, require a workaround or 5 hours to figure out how to maybe doing something…

Why would you make the custom template only available in a grid and not all applications?

thanks,

David

Re: Using Templates with Scriptcase (Custom Grid/Reports)

And please publish your original templates as start point for custom templates.

Thank you
Arno

Re: Using Templates with Scriptcase (Custom Grid/Reports)

^^^^^^^^^^

This. If you want to tweak something, this is a pre-requisite.

Re: Using Templates with Scriptcase (Custom Grid/Reports)

hi there!

this is a great feature.
but: where and how can i put the “tools”? like: next, search, buttons and so on? cant find that. maybe i am blind :slight_smile:

Re: Using Templates with Scriptcase (Custom Grid/Reports)

This seems to be applicable for SC 5, but it won’t work in SC 6. Can somebody update this for SC 6?

Re: Using Templates with Scriptcase (Custom Grid/Reports)

well, I wonder if any of existing MockUp tools would help creating SC templates.
There should be definitely mor examples on customizing the look of Applications, as SC is missing Visual Design Tool.

Hello All, what do {NM_CAB_LOGOTIPO}, {NM_CSS_CAB}, {NM_CAB_DATA} mean? I am trying to create my own html templates.

Is it possible to use the nested grid and populate the fields in the base grid body html? or do you have to use the onrecord event with the sql statement and create the array to populate the custom html template that is applied to the base grid application?

There’s my question … but I don’t see the answer … how do I put the buttons … edit / delete on the grid lines of the html template?