1 <%@ Page Language="VB" ResponseEncoding="iso-8859-1" Debug="true" %>
\r
2 <%@ Register TagPrefix="Rico" Assembly="Rico" NameSpace="Rico" %>
\r
3 <%@ Register TagPrefix="My" TagName="dbLib" Src="dbConnect.ascx" %>
\r
4 <My:dbLib id='app' runat='server' />
\r
6 <script runat="server">
\r
8 Sub Page_Load(Sender As object, e As EventArgs)
\r
9 dim category,lastCategory,Discounts,Gross,subtotals(1),grandtotals(1),i
\r
12 if not app.OpenDB() then exit sub
\r
18 command = app.dbConnection.CreateCommand()
\r
19 command.CommandText="select CategoryName,ProductName, " & _
\r
20 "SUM(od.UnitPrice*Quantity) as GrossSales, " & _
\r
21 "SUM(od.UnitPrice*Quantity*Discount) as Discounts " & _
\r
22 "from ((Order_Details od " & _
\r
23 "inner join Products p on p.ProductID=od.ProductID) " & _
\r
24 "inner join Categories c on p.CategoryID=c.CategoryID) " & _
\r
25 "group by CategoryName,ProductName " & _
\r
26 "order by CategoryName,ProductName"
\r
27 rdr = command.ExecuteReader()
\r
29 category=rdr("CategoryName")
\r
30 Gross=rdr("GrossSales")
\r
31 Discounts=rdr("Discounts")
\r
32 if category<>lastCategory then
\r
33 if not IsNothing(lastCategory) then
\r
34 AddRow("Subtotal",subtotals(0),subtotals(1),"Subtotal")
\r
37 ex1.AddCell(new SimpleGrid.TextCell(category, "CatHead"))
\r
38 ex1.AddCell(new SimpleGrid.TextCell("", "CatHead"))
\r
39 ex1.AddCell(new SimpleGrid.TextCell("", "CatHead"))
\r
40 ex1.AddCell(new SimpleGrid.TextCell("", "CatHead"))
\r
41 ex1.AddCell(new SimpleGrid.TextCell("", "CatHead"))
\r
45 lastCategory=category
\r
48 grandtotals(0)+=Gross
\r
49 subtotals(1)+=Discounts
\r
50 grandtotals(1)+=Discounts
\r
51 AddRow(rdr("ProductName"),Gross,Discounts,"")
\r
54 if not IsNothing(lastCategory) then
\r
55 AddRow("Subtotal",subtotals(0),subtotals(1),"Subtotal")
\r
57 AddRow("Grand Total",grandtotals(0),grandtotals(1),"GrandTotal")
\r
60 sub AddRow(ProductName as String, Gross as Double, Discounts as Double, StyleId as String)
\r
63 ex1.AddCell(new SimpleGrid.TextCell(ProductName, StyleId))
\r
64 ex1.AddCell(new SimpleGrid.NumberCell(Gross, StyleId & "Number"))
\r
65 ex1.AddCell(new SimpleGrid.NumberCell(Discounts, StyleId & "Number"))
\r
66 ex1.AddCell(new SimpleGrid.NumberCell(Gross-Discounts, StyleId & "Number"))
\r
68 ex1.AddCell(new SimpleGrid.NumberCell(pct, StyleId & "Percent"))
\r
71 Protected Overrides Sub Render(writer as HTMLTextWriter)
\r
72 select case lcase(Request.QueryString("fmt"))
\r
73 case "xl": ex1.RenderExcel("ProductSalesSummary.xml")
\r
74 case "csv": ex1.RenderDelimited("ProductSalesSummary.csv")
\r
75 case else: MyBase.Render(writer) ' output html
\r
81 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
\r
84 <title>Rico SimpleGrid-Example 1</title>
\r
86 <Rico:LoadClient checkQueryString='true' runat='server' />
\r
87 <link href="../demo.css" type="text/css" rel="stylesheet" />
\r
90 <script type='text/javascript'>
\r
91 function ExportGridClient() {
\r
92 ex1['grid'].printVisible();
\r
95 function ExportGridServer(ExportType) {
\r
97 location.href+='&fmt='+ExportType;
\r
99 window.open(location.href+'&fmt='+ExportType);
\r
108 <div id='explanation'>
\r
110 <script type='text/javascript'>
\r
111 document.write(Rico.Lib+' '+Rico.LibVersion);
\r
114 <p><strong>Rico: SimpleGrid</strong></p>
\r
115 <p>Rico's SimpleGrid is an unbuffered grid - all data exists in the DOM.
\r
116 It shares many of the same characteristics as Rico's better known LiveGrid.
\r
117 SimpleGrids have resizable columns, frozen columns on the left, and can use the
\r
118 same CSS styling as LiveGrids. Sorting and filtering can also be enabled
\r
119 at the developer's discretion. Unlike LiveGrids, each cell in a SimpleGrid
\r
120 can be formatted individually.
\r
125 <button onclick="ExportGridClient()">Export from client<br>to HTML Table</button>
\r
126 <button onclick="ExportGridServer('xl')">Export from server<br>to Excel</button>
\r
127 <button onclick="ExportGridServer('csv')">Export from server<br>to CSV</button>
\r
130 <Rico:SimpleGrid runat='server' id='ex1' frozenColumns='1'>
\r
131 <Rico:Style runat='server' StyleID='CatHead' BackColor="blue" ForeColor="white" bold="true" />
\r
132 <Rico:Style runat='server' StyleID='Subtotal' BackColor="#888888" ForeColor="white" bold="true" />
\r
133 <Rico:Style runat='server' StyleID='GrandTotal' BackColor="black" ForeColor="white" bold="true" />
\r
134 <Rico:Style runat='server' StyleID='Number' NumberFormat="$#,##0" HorizontalAlign="right" />
\r
135 <Rico:Style runat='server' StyleID='SubtotalNumber' NumberFormat="$#,##0" HorizontalAlign="right" BackColor="#888888" ForeColor="white" bold="true" />
\r
136 <Rico:Style runat='server' StyleID='GrandTotalNumber' NumberFormat="$#,##0" HorizontalAlign="right" BackColor="black" ForeColor="white" bold="true" />
\r
137 <Rico:Style runat='server' StyleID='Percent' NumberFormat="0%" HorizontalAlign="right" />
\r
138 <Rico:Style runat='server' StyleID='SubtotalPercent' NumberFormat="0%" HorizontalAlign="right" BackColor="#888888" ForeColor="white" bold="true" />
\r
139 <Rico:Style runat='server' StyleID='GrandTotalPercent' NumberFormat="0%" HorizontalAlign="right" BackColor="black" ForeColor="white" bold="true" />
\r
141 <Rico:SimpleCol runat='server' heading="Product" width='200' />
\r
142 <Rico:SimpleCol runat='server' heading="Gross Sales" />
\r
143 <Rico:SimpleCol runat='server' heading="Discounts" />
\r
144 <Rico:SimpleCol runat='server' heading="Net Sales" />
\r
145 <Rico:SimpleCol runat='server' heading="Avg Discount" />
\r