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 = "LoadRicoClient.asp" -->
\r
9 <!-- #INCLUDE FILE = "../../plugins/asp/SimpleGrid.vbs" -->
\r
11 <link href="../demo.css" type="text/css" rel="stylesheet" />
\r
14 <script type='text/javascript'>
\r
15 Rico.loadModule('SimpleGrid');
\r
18 Rico.onLoad( function() {
\r
20 columnSpecs : [{width:200},'specQty','specQty','specQty','specQty']
\r
22 ex1=new Rico.SimpleGrid ('ex1', opts);
\r
23 if (!Rico.isIE) document.getElementById('owc').disabled=true;
\r
26 function ExportGridClient(ExportType) {
\r
27 ex1.printVisible(ExportType);
\r
30 function ExportGridServer(ExportType) {
\r
31 if (Prototype.Browser.IE) {
\r
32 location.href+='&fmt='+ExportType;
\r
34 window.open(location.href+'&fmt='+ExportType);
\r
39 <style type="text/css">
\r
43 font-weight:bold !important;
\r
48 font-weight:bold !important;
\r
53 font-weight:bold !important;
\r
65 <div id='explanation'>
\r
67 <script type='text/javascript'>
\r
68 document.write(Rico.Lib+' '+Rico.LibVersion);
\r
71 <p><strong>Rico: SimpleGrid</strong></p>
\r
72 <p>Rico's SimpleGrid is an unbuffered grid - all data exists in the DOM.
\r
73 It shares many of the same characteristics as Rico's better known LiveGrid.
\r
74 SimpleGrids have resizable columns, frozen columns on the left, and can use the
\r
75 same CSS styling as LiveGrids. Sorting and filtering can also be enabled
\r
76 at the developer's discretion. Unlike LiveGrids, each cell in a SimpleGrid
\r
77 can be formatted individually.
\r
82 <button onclick="ExportGridClient('plain')">Export from client<br>to HTML Table</button>
\r
83 <button onclick="ExportGridClient('owc')" id="owc">Export from client<br>to OWC spreadsheet</button>
\r
84 <button onclick="ExportGridServer('xl')">Export from server<br>to Excel</button>
\r
85 <button onclick="ExportGridServer('csv')">Export from server<br>to CSV</button>
\r
93 response.write "<p>ERROR opening database!"
\r
95 set grid=new SimpleGrid ' create instance of class
\r
97 select case lcase(Request.QueryString("fmt"))
\r
98 case "xl": grid.RenderExcel "rico.xls"
\r
99 case "csv": grid.RenderDelimited "rico.csv", ",", ""
\r
100 case else: grid.Render "ex1", 1 ' output html
\r
102 set grid=Nothing ' clean up
\r
107 dim rsMain,sqltext,category,lastCategory,Discounts,Gross,subtotals(1),grandtotals(1),i
\r
114 grid.AddHeadingRow true
\r
115 grid.AddCell "Product"
\r
116 grid.AddCell "Gross Sales"
\r
117 grid.AddCell "Discounts"
\r
118 grid.AddCell "Net Sales"
\r
119 grid.AddCell "Avg Discount"
\r
121 sqltext="select CategoryName,ProductName, " & _
\r
122 "SUM(od.UnitPrice*Quantity) as GrossSales, " & _
\r
123 "SUM(od.UnitPrice*Quantity*Discount) as Discounts " & _
\r
124 "from ((Order_Details od " & _
\r
125 "inner join Products p on p.ProductID=od.ProductID) " & _
\r
126 "inner join Categories c on p.CategoryID=c.CategoryID) " & _
\r
127 "group by CategoryName,ProductName " & _
\r
128 "order by CategoryName,ProductName"
\r
129 set rsMain = oDB.RunQuery(sqltext)
\r
130 while not rsMain.eof
\r
131 category=rsMain("CategoryName")
\r
132 Gross=rsMain("GrossSales")
\r
133 Discounts=rsMain("Discounts")
\r
134 if category<>lastCategory then
\r
135 if not IsEmpty(lastCategory) then
\r
136 AddRow "Subtotal",subtotals(0),subtotals(1)
\r
137 grid.SetRowAttr "class","Subtotal"
\r
140 grid.SetRowAttr "class","CatHead"
\r
141 grid.AddCell category
\r
149 lastCategory=category
\r
151 subtotals(0)=subtotals(0)+Gross
\r
152 grandtotals(0)=grandtotals(0)+Gross
\r
153 subtotals(1)=subtotals(1)+Discounts
\r
154 grandtotals(1)=grandtotals(1)+Discounts
\r
155 AddRow rsMain("ProductName"),Gross,Discounts
\r
159 if not IsEmpty(lastCategory) then
\r
160 AddRow "Subtotal",subtotals(0),subtotals(1)
\r
161 grid.SetRowAttr "class","Subtotal"
\r
163 AddRow "Grand Total",grandtotals(0),grandtotals(1)
\r
164 grid.SetRowAttr "class","GrandTotal"
\r
168 sub AddRow(ProductName,Gross,Discounts)
\r
170 grid.AddCell Server.HTMLencode(ProductName)
\r
171 grid.AddCell "$" & FormatNumber(Gross,0,-1,0,-1)
\r
172 grid.AddCell "$" & FormatNumber(Discounts,0,-1,0,-1)
\r
173 grid.AddCell "$" & FormatNumber(Gross-Discounts,0,-1,0,-1)
\r
174 grid.AddCell round(Discounts/Gross*100.0) & "%"
\r