| Data Export |
It is easy to understand in the master/slave operations where a key is picked in from master table and the slave use this key to construct a query to supply the details. Tornado extends the Data Export envelop to cover the following area -
A Raw format is the native data value like integer 3. An HTML format is the same field data being masked and displayed like $3.00. The HTML format is the blue color $3.00 . These two formats are required in different situation - Raw format is used in computation and charting while HTML format is for display.
Export Fields and Columns
|
<!--T_Export_1.aspx-->
<script language="vb" runat="server"> |
Not that field 1 and column 5 are exported in raw format. All the exported data can be retrieved by via a Tornado.GetData call. The grid display indicated that a system index is added for navigation. Click the Index '#' will change the active row and the fields exports will reflect the change.
Array Formatter - Lists
The above example process the exported data manually. Tornado has a feature called 'Array Formatter' which allow user to arrange the exported data into many formats. The following example is a 'List' example. the exported data is formatted as <OL> and <UL> in the template.
|
<!--T_Export_2.aspx--> <script runat="server"> |
Array Formatter - Table Rows and Columns
Now, we are going to go a bit deeper and combine Export data and MagicCell filter to illustrate how easy it is to apply the powerful features of Tornado.
|
<!--T_Export_3.aspx--> <script runat="server"> Sub Page_Load(Source as Object, E as EventArgs) Dim MemTemp As String = "<center>[[title]]<p>[[XC::98::0::4CV]]<P>[[GridNav]]<P>[[GridStat]]</center>" Dim Tmpx3 As New Tornado.Z() With Tmpx3 .dbQP = "U=98| S=29|Gtp=[[Grid]]| Ps=16| D=Car2000.mdb| Rc=227| Xc=Picture| Iv=t| Th=tit=Advanced Magic Export" .dbSQL = "Select Yr, Car, Price, Picture From Carspecs" .dbGridMagicCell = "field=Picture|macro=(/tornado/db/images-car/#Picture#|FX|True||<IMG WIDTH=150 BORDER=0 VSPACE=0 HSPACE=0 SRC='/tornado/notruck.jpg'>~#price#|GT|35000||<A HREF='/tornado/db/images-car/#Picture#'><IMG WIDTH=150 BORDER=0 VSPACE=0 HSPACE=0 SRC='/tornado/db/images-car/#Picture#' ALT='Click to see large picture'></A><br>#yr# #Car#<br><Strike>#Price:currency#</Strike> <<#Price# * 0.85::Currency>> ~ #Price:Currency#|EL|||<A HREF='/tornado/db/images-car/#Picture#'><IMG WIDTH=150 BORDER=0 VSPACE=0 HSPACE=0 SRC='/tornado/db/images-car/#Picture#' ALT='Click to see large picture'></A><br>#yr# #Car#<br>#Price:currency#)" .ASPdbNET() .ASPdbSendTemplate("display", , MemTemp) End with End Sub </script> |
In this example, we export just one column - 'picture', but we packed in it Year, Name, Price and Picture.
In the display template, we specify a Block-Row-Col type of formatting - [[XC::98::0::4CV]] means The data source is from Export Column unit 98 column 0. The array formatter is 4CV (4 columns in the vertical direction) with a page size of 16. The rest of the details will be filled in automatically. Further more, we'll apply the MagicCell filter to turn the picture into thumbnails; display the year, name, and price data below the thumbnail; if there is no picture data, display a no-show image instead; display the price as currency; if the price is > $35,000 then give it a 15% discount.
Now, can you feel the power of Tornado!