1 <%@ Page Language="VB" ResponseEncoding="iso-8859-1" Debug="true" %>
\r
2 <%@ Register TagPrefix="Rico" TagName="SimpleGrid" Src="../../plugins/dotnet/SimpleGrid.ascx" %>
\r
3 <%@ Register TagPrefix="Rico" TagName="Column" Src="../../plugins/dotnet/GridColumn.ascx" %>
\r
4 <%@ Register TagPrefix="My" TagName="LoadRicoClient" Src="LoadRicoClient.ascx" %>
\r
5 <%@ Register TagPrefix="My" TagName="dbLib" Src="dbConnect.ascx" %>
\r
6 <My:dbLib id='app' runat='server' />
\r
8 <script runat="server">
\r
10 Sub Page_Load(Sender As object, e As EventArgs)
\r
11 dim category,lastCategory,Discounts,Gross,subtotals(1),grandtotals(1),i
\r
14 if not app.OpenDB() then exit sub
\r
21 ex1.AddHeadingRow(true)
\r
22 ex1.AddCell("Product")
\r
23 ex1.AddCell("Gross Sales")
\r
24 ex1.AddCell("Discounts")
\r
25 ex1.AddCell("Net Sales")
\r
26 ex1.AddCell("Avg Discount")
\r
28 command = app.dbConnection.CreateCommand()
\r
29 command.CommandText="select CategoryName,ProductName, " & _
\r
30 "SUM(od.UnitPrice*Quantity) as GrossSales, " & _
\r
31 "SUM(od.UnitPrice*Quantity*Discount) as Discounts " & _
\r
32 "from ((Order_Details od " & _
\r
33 "inner join Products p on p.ProductID=od.ProductID) " & _
\r
34 "inner join Categories c on p.CategoryID=c.CategoryID) " & _
\r
35 "group by CategoryName,ProductName " & _
\r
36 "order by CategoryName,ProductName"
\r
37 rdr = command.ExecuteReader()
\r
39 category=rdr("CategoryName")
\r
40 Gross=rdr("GrossSales")
\r
41 Discounts=rdr("Discounts")
\r
42 if category<>lastCategory then
\r
43 if not IsNothing(lastCategory) then
\r
44 AddRow("Subtotal",subtotals(0),subtotals(1))
\r
45 ex1.SetRowAttr("class","Subtotal")
\r
48 ex1.SetRowAttr("class","CatHead")
\r
49 ex1.AddCell(category)
\r
57 lastCategory=category
\r
60 grandtotals(0)+=Gross
\r
61 subtotals(1)+=Discounts
\r
62 grandtotals(1)+=Discounts
\r
63 AddRow(rdr("ProductName"),Gross,Discounts)
\r
66 if not IsNothing(lastCategory) then
\r
67 AddRow("Subtotal",subtotals(0),subtotals(1))
\r
68 ex1.SetRowAttr("class","Subtotal")
\r
70 AddRow("Grand Total",grandtotals(0),grandtotals(1))
\r
71 ex1.SetRowAttr("class","GrandTotal")
\r
74 sub AddRow(ProductName as String, Gross as Double, Discounts as Double)
\r
77 ex1.AddCell(ProductName)
\r
78 ex1.AddCell("$" & FormatNumber(Gross,0,-1,0,-1))
\r
79 ex1.AddCell("$" & FormatNumber(Discounts,0,-1,0,-1))
\r
80 ex1.AddCell("$" & FormatNumber(Gross-Discounts,0,-1,0,-1))
\r
82 ex1.AddCell(pct.toString("0%"))
\r
85 Protected Overrides Sub Render(writer as HTMLTextWriter)
\r
86 select case lcase(Request.QueryString("fmt"))
\r
87 case "xl": ex1.RenderExcel("rico.xls")
\r
88 case "csv": ex1.RenderDelimited("rico.csv", ",", "")
\r
89 case else: MyBase.Render(writer) ' output html
\r
95 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
\r
98 <title>Rico SimpleGrid-Example 1</title>
\r
100 <My:LoadRicoClient id='initlibs' runat='server' />
\r
101 <link href="../demo.css" type="text/css" rel="stylesheet" />
\r
104 <script type='text/javascript'>
\r
105 Rico.loadModule('SimpleGrid');
\r
107 Rico.onLoad( function() {
\r
108 if (!Rico.isIE) document.getElementById('owc').disabled=true;
\r
111 function ExportGridClient(ExportType) {
\r
112 ex1['grid'].printVisible(ExportType);
\r
115 function ExportGridServer(ExportType) {
\r
117 location.href+='&fmt='+ExportType;
\r
119 window.open(location.href+'&fmt='+ExportType);
\r
124 <style type="text/css">
\r
128 font-weight:bold !important;
\r
133 font-weight:bold !important;
\r
138 font-weight:bold !important;
\r
141 white-space:nowrap;
\r
149 <table id='explanation' border='0' cellpadding='0' cellspacing='5' style='clear:both'><tr valign='top'><td>
\r
151 <script type='text/javascript'>
\r
152 document.write(Rico.Lib+' '+Rico.LibVersion);
\r
155 <p><strong>Rico: SimpleGrid</strong></p>
\r
156 <p>Rico's SimpleGrid is an unbuffered grid - all data exists in the DOM.
\r
157 It shares many of the same characteristics as Rico's better known LiveGrid.
\r
158 SimpleGrids have resizable columns, frozen columns on the left, and can use the
\r
159 same CSS styling as LiveGrids. Sorting and filtering can also be enabled
\r
160 at the developer's discretion. Unlike LiveGrids, each cell in a SimpleGrid
\r
161 can be formatted individually.
\r
164 <script type="text/javascript"><!--
\r
165 google_ad_client = "pub-7218597156507462";
\r
166 /* 125x125, created 5/11/09 */
\r
167 google_ad_slot = "9298106441";
\r
168 google_ad_width = 125;
\r
169 google_ad_height = 125;
\r
172 <script type="text/javascript"
\r
173 src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
\r
180 <button onclick="ExportGridClient('plain')">Export from client<br>to HTML Table</button>
\r
181 <button onclick="ExportGridClient('owc')" id="owc">Export from client<br>to OWC spreadsheet</button>
\r
182 <button onclick="ExportGridServer('xl')">Export from server<br>to Excel</button>
\r
183 <button onclick="ExportGridServer('csv')">Export from server<br>to CSV</button>
\r
186 <Rico:SimpleGrid runat='server' id='ex1' FrozenCols='1'>
\r
188 <Rico:Column runat='server' width='200' />
\r
189 <Rico:Column runat='server' spec='specQty' />
\r
190 <Rico:Column runat='server' spec='specQty' />
\r
191 <Rico:Column runat='server' spec='specQty' />
\r
192 <Rico:Column runat='server' spec='specQty' />
\r