<%@ LANGUAGE="VBSCRIPT" %> Rico SimpleGrid-Example 1 <% Dim RicoClient set RicoClient = new LoadRicoClient RicoClient.SetRicoClientParentPath "../../ricoClient/" RicoClient.CheckQueryString ' just for demo RicoClient.CreateLinks set RicoClient = Nothing %>
Base Library:

Rico: SimpleGrid

Rico's SimpleGrid is an unbuffered grid - all data exists in the DOM. It shares many of the same characteristics as Rico's better known LiveGrid. SimpleGrids have resizable columns, frozen columns on the left, and can use the same CSS styling as LiveGrids. Sorting and filtering can also be enabled at the developer's discretion. Unlike LiveGrids, each cell in a SimpleGrid can be formatted individually.

<% dim grid if not OpenDB then response.write "

ERROR opening database!" else set grid=new SimpleGrid ' create instance of class FillGrid select case lcase(Request.QueryString("fmt")) case "xl": grid.RenderExcel "rico.xls" case "csv": grid.RenderDelimited "rico.csv", ",", "" case else: grid.Render "ex1", 1 ' output html end select set grid=Nothing ' clean up end if sub FillGrid() dim rsMain,sqltext,category,lastCategory,Discounts,Gross,subtotals(1),grandtotals(1),i for i=0 to 1 grandtotals(i)=0 next ' define heading grid.AddHeadingRow true grid.AddCell "Product" grid.AddCell "Gross Sales" grid.AddCell "Discounts" grid.AddCell "Net Sales" grid.AddCell "Avg Discount" sqltext="select CategoryName,ProductName, " & _ "SUM(od.UnitPrice*Quantity) as GrossSales, " & _ "SUM(od.UnitPrice*Quantity*Discount) as Discounts " & _ "from ((Order_Details od " & _ "inner join Products p on p.ProductID=od.ProductID) " & _ "inner join Categories c on p.CategoryID=c.CategoryID) " & _ "group by CategoryName,ProductName " & _ "order by CategoryName,ProductName" set rsMain = oDB.RunQuery(sqltext) while not rsMain.eof category=rsMain("CategoryName") Gross=rsMain("GrossSales") Discounts=rsMain("Discounts") if category<>lastCategory then if not IsEmpty(lastCategory) then AddRow "Subtotal",subtotals(0),subtotals(1) grid.SetRowAttr "class","Subtotal" end if grid.AddDataRow grid.SetRowAttr "class","CatHead" grid.AddCell category grid.AddCell "" grid.AddCell "" grid.AddCell "" grid.AddCell "" for i=0 to 1 subtotals(i)=0 next lastCategory=category end if subtotals(0)=subtotals(0)+Gross grandtotals(0)=grandtotals(0)+Gross subtotals(1)=subtotals(1)+Discounts grandtotals(1)=grandtotals(1)+Discounts AddRow rsMain("ProductName"),Gross,Discounts rsMain.movenext wend oDB.rsClose rsMain if not IsEmpty(lastCategory) then AddRow "Subtotal",subtotals(0),subtotals(1) grid.SetRowAttr "class","Subtotal" end if AddRow "Grand Total",grandtotals(0),grandtotals(1) grid.SetRowAttr "class","GrandTotal" end sub sub AddRow(ProductName,Gross,Discounts) grid.AddDataRow grid.AddCell Server.HTMLencode(ProductName) grid.AddCell "$" & FormatNumber(Gross,0,-1,0,-1) grid.AddCell "$" & FormatNumber(Discounts,0,-1,0,-1) grid.AddCell "$" & FormatNumber(Gross-Discounts,0,-1,0,-1) grid.AddCell round(Discounts/Gross*100.0) & "%" end sub %>