1 <%@ LANGUAGE="VBSCRIPT" %>
\r
2 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
\r
5 <title>Rico SimpleGrid-Example 1</title>
\r
7 <!-- #INCLUDE FILE = "dbConnect.asp" -->
\r
8 <!-- #INCLUDE FILE = "../../plugins/asp/SimpleGrid.vbs" -->
\r
9 <!-- #INCLUDE FILE = "../../plugins/asp/LoadRicoClient.asp" -->
\r
12 set RicoClient = new LoadRicoClient
\r
13 RicoClient.SetRicoClientParentPath "../../ricoClient/"
\r
14 RicoClient.CheckQueryString ' just for demo
\r
15 RicoClient.CreateLinks
\r
16 set RicoClient = Nothing
\r
19 <link href="../demo.css" type="text/css" rel="stylesheet" />
\r
21 <script type='text/javascript'>
\r
24 Rico.onLoad( function() {
\r
26 columnSpecs : [{width:200},'specQty','specQty','specQty','specQty']
\r
28 ex1=new Rico.SimpleGrid ('ex1', opts);
\r
31 function ExportGridClient() {
\r
35 function ExportGridServer(ExportType) {
\r
36 if (Prototype.Browser.IE) {
\r
37 location.href+='&fmt='+ExportType;
\r
39 window.open(location.href+'&fmt='+ExportType);
\r
44 <style type="text/css">
\r
48 font-weight:bold !important;
\r
53 font-weight:bold !important;
\r
58 font-weight:bold !important;
\r
70 <div id='explanation'>
\r
72 <script type='text/javascript'>
\r
73 document.write(Rico.Lib+' '+Rico.LibVersion);
\r
76 <p><strong>Rico: SimpleGrid</strong></p>
\r
77 <p>Rico's SimpleGrid is an unbuffered grid - all data exists in the DOM.
\r
78 It shares many of the same characteristics as Rico's better known LiveGrid.
\r
79 SimpleGrids have resizable columns, frozen columns on the left, and can use the
\r
80 same CSS styling as LiveGrids. Sorting and filtering can also be enabled
\r
81 at the developer's discretion. Unlike LiveGrids, each cell in a SimpleGrid
\r
82 can be formatted individually.
\r
87 <button onclick="ExportGridClient()">Export from client<br>to HTML Table</button>
\r
88 <button onclick="ExportGridServer('xl')">Export from server<br>to Excel</button>
\r
89 <button onclick="ExportGridServer('csv')">Export from server<br>to CSV</button>
\r
97 response.write "<p>ERROR opening database!"
\r
99 set grid=new SimpleGrid ' create instance of class
\r
101 select case lcase(Request.QueryString("fmt"))
\r
102 case "xl": grid.RenderExcel "rico.xls"
\r
103 case "csv": grid.RenderDelimited "rico.csv", ",", ""
\r
104 case else: grid.Render "ex1", 1 ' output html
\r
106 set grid=Nothing ' clean up
\r
111 dim rsMain,sqltext,category,lastCategory,Discounts,Gross,subtotals(1),grandtotals(1),i
\r
118 grid.AddHeadingRow true
\r
119 grid.AddCell "Product"
\r
120 grid.AddCell "Gross Sales"
\r
121 grid.AddCell "Discounts"
\r
122 grid.AddCell "Net Sales"
\r
123 grid.AddCell "Avg Discount"
\r
125 sqltext="select CategoryName,ProductName, " & _
\r
126 "SUM(od.UnitPrice*Quantity) as GrossSales, " & _
\r
127 "SUM(od.UnitPrice*Quantity*Discount) as Discounts " & _
\r
128 "from ((Order_Details od " & _
\r
129 "inner join Products p on p.ProductID=od.ProductID) " & _
\r
130 "inner join Categories c on p.CategoryID=c.CategoryID) " & _
\r
131 "group by CategoryName,ProductName " & _
\r
132 "order by CategoryName,ProductName"
\r
133 set rsMain = oDB.RunQuery(sqltext)
\r
134 while not rsMain.eof
\r
135 category=rsMain("CategoryName")
\r
136 Gross=rsMain("GrossSales")
\r
137 Discounts=rsMain("Discounts")
\r
138 if category<>lastCategory then
\r
139 if not IsEmpty(lastCategory) then
\r
140 AddRow "Subtotal",subtotals(0),subtotals(1)
\r
141 grid.SetRowAttr "class","Subtotal"
\r
144 grid.SetRowAttr "class","CatHead"
\r
145 grid.AddCell category
\r
153 lastCategory=category
\r
155 subtotals(0)=subtotals(0)+Gross
\r
156 grandtotals(0)=grandtotals(0)+Gross
\r
157 subtotals(1)=subtotals(1)+Discounts
\r
158 grandtotals(1)=grandtotals(1)+Discounts
\r
159 AddRow rsMain("ProductName"),Gross,Discounts
\r
163 if not IsEmpty(lastCategory) then
\r
164 AddRow "Subtotal",subtotals(0),subtotals(1)
\r
165 grid.SetRowAttr "class","Subtotal"
\r
167 AddRow "Grand Total",grandtotals(0),grandtotals(1)
\r
168 grid.SetRowAttr "class","GrandTotal"
\r
172 sub AddRow(ProductName,Gross,Discounts)
\r
174 grid.AddCell Server.HTMLencode(ProductName)
\r
175 grid.AddCell "$" & FormatNumber(Gross,0,-1,0,-1)
\r
176 grid.AddCell "$" & FormatNumber(Discounts,0,-1,0,-1)
\r
177 grid.AddCell "$" & FormatNumber(Gross-Discounts,0,-1,0,-1)
\r
178 grid.AddCell round(Discounts/Gross*100.0) & "%"
\r