Tornado Class Library

Special Topic - Templates

 
System Template

 

The Tornado display system uses templates throughout and is extremely flexible. Templates are sent to the browser after all the [[macros]] objects are generated by and stuffed. This method becomes a special case display tool as all of the standard modes display templates are covered by the standard template. Therefore, use the macros defined for the standard templates.

A System Template has the format of -  <center>[Action]]</center>  where Action = Update, Add, Filter

 

The following system templates can be override by issuing a new one to the properties.

System Templates Default
dbAddTemplate <center>[[NormalAdd]]</center>
dbAggregateExportTemplate See dbAggregateExportTemplate
dbDualTemplate <center><table border=0><tr valign=top><td>[[Grid]]</td><td>[[Form]]</td>
</tr></table><p>[[GridNav]]<P>[[GridStat]]</center>
dbDualTemplate <center>[[Grid]]<p>[[Form]]<p>[[GridNav]]<P>[[GridStat]]</center>
dbFilterTemplate <center>[[NormalFilter]]</center>
dbFormTemplate <center>[[Form]]<p>[[GridNav]]<P>[[GridStat]]</center>
dbGridTemplate <center>[[Grid]]<p>[[GridNav]]<P>[[GridStat]]</center>

Example - Modify for a Grid Chart to display in vertical manner.

Obj.dbGridTemplate = "<center><table border=0><tr valign=top><td align=center>[[Grid]]</td></tr><tr><td align=center><br>[[Chart]]</td></tr></table></Center>

dbLoginTemplate file=ASPdbLogin.htm
dbSelectedBoxFormTemplate <center>[[SelectBox]]<p>[[Form]]<p>[[GridStat]]</center>
dbUpdateTemplate <center>[[NormalUpdate]]</center>

Note: For user Template that includes Filter and Edit, you must wrap that in an <Action>...</Action> block. This block will be displayed or hidden according to the conditions (Cancel). For example -

T.dbGridTemplate = "[[Grid]]<action>[[NormalFilter]]</action><BR>[[GridNav]]<BR>[[GridStat]]"

 

Modifying System Templates

Many times you would like to have your own arrangement of the display templates like navigation on the top. The following is the system Grid template.

GridTemp = "<center><table class=nb><tr valign=top> <td align='center'>[[Grid]]<p><center>[[GridNav]]<P>[[GridStat]]</center></td><action><td> <center>[[Action]]</center></td></action></tr></table><P>[[Memo]]</center>";

[[Action]] will be replaced by Filter and Edit templates.
[[Memo]] will be stuffed by the single memo field if present.

So, to add a navigation bar at the top and you do not have a single memo field ->

T.dbGridTemplate = "<center><table class=nb><tr valign=top><td align='center'>[[GridNav]]<p>[[Grid]]<p><center>[[GridNav]]<P>[[GridStat]]</center></td><action><td> <center>[[Action]]</center></td></action></tr></table></center>"

Single Memo field is a feature to emulate the classic asp-db to place the memo field below the grid. Only (1) field is allowed. See dbMemoFlds proeprty.

 

 

User Template and Macros

User Template macros are used in Editing as well as stand alone ASPdbSendTemplate method.

System Templates Default
dbUserAddTemplate No default - Use HTML and User Template Macros
dbUserFilterTemplate No default - Use HTML and User Template Macros
dbUserUpdateTemplate No default - Use HTML and User Template Macros

 

[[Template Macros]] Description Example
Now Today's day. [[Now(MM-dd-yy)]] or [[now()]]

Now can be applied to Report in User data or Magic.

TX Lay a text anchor. This could be anything including your own controls [[TX::<INPUT....>]]
V Value with format [[V::Value::Format]]

EQ can be applied to Report

SV, F, RF Session Variable, Field, RawField [[SV::VarName::BlankText::Contain Text:: If not Contain Text::If containText]]

RF and SV can be applied to Report.

XF Export Field (Row) [[XF::EXPORT_Index::Unit]]
EXPORT Field = Session(ASPDB_EXPORTFLDS_Index)
XC Export Column (Col) [[XC::Unit::Col::Table BRC]]
EQ Equation [[EQ::Equation::OPR::CMP_VALUE::True-HTML::False-HTML]]
OPR (=, <>,>, >=, <, <=)
False-HTML can be a space for no show

EQ can be applied to Report

CHART Chart output [[Chart]]
GRID Grid output [[Grid]]
FORM Form output [[Form]]
SELECTBOX Select Box output [[SelectBox]]
NORMALFILTER Filter output [[NormalFilter]]
NORMALADD Edit Add output [[NormalAdd]]
GRIDNAV Navigation output [[GridNav]]
GRIDSTAT Stat output [[GridStat]]
MEMO, RAWMEMO Memo field [[0=memo::1=fieldname::2=Macro with ##field##]]

Example - [[memo::notes::<table width='54%' class=ts cellspacing='1'><tr><td class='gh'>Title</td></tr><tr><td class=nr>##field##</td></tr></table>]]

Example for multiple Memo fields -

T.dbGridTemplate = "<center>[[Grid]]<p>[[GridNav]]<p>[[GridStat]]<p><p><table width='54%' class=ts cellspacing='1'><tr><td class='gh'>Activity Desc</td><td class='gh'>Status</td><td class='gh'>Notes</td><td class='gh'>Lesson</td></tr><tr><td class=nr>[[memo::Activity_Descrip::##field##]]</td><td class=nr>[[memo::Status::##field##]]</td><td class=nr>[[memo::Notes::##field##]]</td><td class=nr>[[memo::Lesson::##field##]]</td></tr></table></center>"

The key is to position the [[Memo:Fname:##field##]] in the appropriate place. Remember to set the memotextsize to -1.

 

XC tag - Table BRC (Array Formatter)

In the XC tag (Export Column), the last option is called Table BRC. BRC stands for "Block-Rows-Cols" and is a very flexible blanket layout for items on a matrix. You can just indicate how many rows or columns and the direction of the layout and the rest will be figured out for you. The layout can be a standard table with patch cells or user specified. Look at the Code Gallery Export Formatted Table RC example. This example takes the column output of the database which are image filenames and lay them out in a matrix via a macro. All is specified is '4CV' meaning 4 Columns in the Vertical direction. 

Option for this the XC tag are -

* PatchStr is the string that fills the empty matrix cell like -> N/A or an image. Default is &nbsp;

 

 

Advanced Showcase Example - dbUserAddTemplate

Download, Unzip the following. Execute the UserAddTemplate.aspx file and you'll see a custom Edit Add screen as follows. Inspect the template file and see how it is being done.

Download User Add Template Example files


Send Template

After ASPdbSendTemplate is called, the [[macros]] will be filled with appropriate values.

 


Send comments on this topic.
Copyright 1998-2006 ASP-db