--- /dev/null
+<%\r
+\r
+class SimpleGridCell\r
+ public content\r
+ private attr\r
+\r
+ Private Sub Class_Initialize\r
+ set attr = CreateObject("Scripting.Dictionary")\r
+ End sub\r
+\r
+ Private Sub Class_Terminate\r
+ set attr = Nothing\r
+ End sub\r
+\r
+ Public Function HeadingCell()\r
+ Dim s, span\r
+ s="<td"\r
+ span=1\r
+ If attr.exists("colspan") Then\r
+ span=attr("colspan")\r
+ s=s & " colspan='" & span & "'"\r
+ End If\r
+ HeadingCell = Array(s & "><div class='ricoLG_col'>" & DataCell("") & "</div></td>", span)\r
+ End Function\r
+\r
+ Public Function DataCell(rowclass)\r
+ dim s,k\r
+ s = "<div"\r
+ attr("class")=trim("ricoLG_cell " & attr("class") & " " & rowclass)\r
+ for each k in attr.keys\r
+ If k<>"colspan" Then s=s & " " & k & "='" & attr(k) & "'"\r
+ next\r
+ s=s & ">" & content & "</div>"\r
+ DataCell=s\r
+ End Function\r
+\r
+ Public Function HtmlCell()\r
+ dim s,k\r
+ s = "<td"\r
+ for each k in attr.keys\r
+ s=s & " " & k & "='" & attr(k) & "'"\r
+ next\r
+ s=s & ">" & content & "</td>"\r
+ HtmlCell=s\r
+ End Function\r
+\r
+ Public Sub SetAttr(name,value)\r
+ attr(name)=value\r
+ End Sub\r
+End class\r
+\r
+\r
+class SimpleGridRow\r
+ public cells()\r
+ private attr, CurrentCell\r
+\r
+ Private Sub Class_Initialize\r
+ redim cells(-1)\r
+ set attr = CreateObject("Scripting.Dictionary")\r
+ end sub\r
+\r
+ Private Sub Class_Terminate\r
+ set attr = Nothing\r
+ end sub\r
+ \r
+ Public Sub AddCell(ByVal content)\r
+ ReDim Preserve cells(ubound(cells)+1)\r
+ set CurrentCell=new SimpleGridCell\r
+ set cells(ubound(cells))=CurrentCell\r
+ CurrentCell.content=content\r
+ End Sub\r
+ \r
+ Public Function HeadingRow(ByVal c1, ByVal c2)\r
+ dim cellidx,colidx,s,a\r
+ cellidx=0\r
+ colidx=0\r
+ while colidx < c1 and cellidx <= ubound(cells)\r
+ a=cells(cellidx).HeadingCell()\r
+ colidx=colidx+CInt(a(1))\r
+ cellidx=cellidx+1\r
+ Wend\r
+ while (colidx <= c2) and cellidx <= ubound(cells)\r
+ a=cells(cellidx).HeadingCell()\r
+ s=s & a(0)\r
+ colidx=colidx+CInt(a(1))\r
+ cellidx=cellidx+1\r
+ wend\r
+ HeadingRow = s\r
+ End Function\r
+ \r
+ Public Function HeadingClass()\r
+ HeadingClass=trim("ricoLG_hdg " & attr("class"))\r
+ End Function\r
+ \r
+ Public Function CellCount()\r
+ CellCount=ubound(cells)+1\r
+ End Function\r
+\r
+ Public Function GetRowAttr(ByVal name)\r
+ GetRowAttr=attr(name)\r
+ End Function\r
+\r
+ Public Sub SetRowAttr(ByVal name, ByVal value)\r
+ attr(name)=value\r
+ End Sub\r
+\r
+ Public Sub SetCellAttr(ByVal name, ByVal value)\r
+ CurrentCell.SetAttr name,value\r
+ End Sub\r
+end class\r
+\r
+\r
+class SimpleGrid\r
+ public rows()\r
+ private LastRow,LastHeadingRow,ResizeRowIdx\r
+\r
+ Private Sub Class_Initialize\r
+ redim rows(-1)\r
+ End sub\r
+\r
+ Public Function AddHeadingRow(ResizeRowFlag)\r
+ LastHeadingRow=AddDataRow\r
+ if ResizeRowFlag then ResizeRowIdx=LastHeadingRow\r
+ AddHeadingRow=LastHeadingRow\r
+ End Function\r
+ \r
+ Public Function AddDataRow()\r
+ ReDim Preserve rows(ubound(rows)+1)\r
+ set rows(ubound(rows))=new SimpleGridRow\r
+ LastRow=ubound(rows)\r
+ AddDataRow=LastRow\r
+ End Function\r
+ \r
+ Public Function HeadingRowCount()\r
+ if IsEmpty(LastHeadingRow) then\r
+ HeadingRowCount=0\r
+ else\r
+ HeadingRowCount=LastHeadingRow+1\r
+ end if\r
+ End Function\r
+ \r
+ Public Function DataRowCount()\r
+ if IsEmpty(LastRow) then\r
+ DataRowCount=0\r
+ else\r
+ DataRowCount=LastRow+1-HeadingRowCount()\r
+ end if\r
+ End Function\r
+ \r
+ ' returns # of cells in the current row\r
+ Public Function CellCount()\r
+ CellCount=rows(LastRow).CellCount\r
+ End Function\r
+\r
+ Public Sub AddCell(ByVal content)\r
+ rows(LastRow).AddCell content\r
+ End Sub\r
+ \r
+ Public Sub AddCellToRow(ByVal RowIdx, ByVal content)\r
+ LastRow=RowIdx\r
+ AddCell content\r
+ End Sub\r
+ \r
+ Public Sub SetRowAttr(ByVal name, ByVal value)\r
+ rows(LastRow).SetRowAttr name,value\r
+ End Sub\r
+\r
+ Public Sub SetCellAttr(ByVal name, ByVal value)\r
+ rows(LastRow).SetCellAttr name,value\r
+ End Sub\r
+\r
+ Private Function RenderColumns(ByVal c1, ByVal c2)\r
+ dim r,c\r
+ for c=c1 to c2\r
+ response.write vbLf & "<td><div class='ricoLG_col'>"\r
+ for r=LastHeadingRow+1 to ubound(rows)\r
+ response.write rows(r).cells(c).DataCell(rows(r).GetRowAttr("class"))\r
+ next\r
+ response.write "</div></td>"\r
+ next\r
+ End Function\r
+\r
+ ' Response.Buffer must be true\r
+ Public Sub RenderExcel(fileName)\r
+ dim r,c\r
+ Response.Clear\r
+ if fileName<>"" then Response.AddHeader "content-disposition", "attachment; filename=" & fileName\r
+ 'Response.ContentType = "application/vnd.ms-excel"\r
+ Response.ContentType = "application/ms-excel"\r
+\r
+ response.write vbLf & "<table>"\r
+ for r=0 to ubound(rows)\r
+ response.write vbLf & "<tr>"\r
+ for c=0 to ubound(rows(r).cells)\r
+ response.write rows(r).cells(c).HtmlCell\r
+ next\r
+ response.write vbLf & "</tr>"\r
+ next\r
+ response.write vbLf & "</table>"\r
+ Response.End\r
+ End Sub\r
+\r
+ ' Response.Buffer must be true\r
+ Public Sub RenderDelimited(fileName,delim,SubstituteChar)\r
+ dim r,c\r
+ Response.Clear\r
+ if fileName<>"" then Response.AddHeader "content-disposition", "attachment; filename=" & fileName\r
+ Response.ContentType = "text/csv"\r
+\r
+ for r=0 to ubound(rows)\r
+ for c=0 to ubound(rows(r).cells)\r
+ if c > 0 then response.write delim\r
+ response.write replace(rows(r).cells(c).content,delim,SubstituteChar)\r
+ next\r
+ response.write vbLf\r
+ next\r
+ Response.End\r
+ End Sub\r
+\r
+ Public Sub Render(ByVal id, FrozenCols)\r
+ dim colcnt,r,c\r
+ if IsEmpty(ResizeRowIdx) then exit sub\r
+ colcnt=rows(ResizeRowIdx).CellCount\r
+ response.write vbLf & "<div id='" & id & "_outerDiv'>"\r
+\r
+ '-------------------\r
+ ' frozen columns\r
+ '-------------------\r
+ response.write vbLf & "<div id='" & id & "_frozenTabsDiv'>"\r
+\r
+ ' upper left\r
+ response.write vbLf & "<table id='" & id & "_tab0h' class='ricoLG_table ricoLG_top ricoLG_left' cellspacing='0' cellpadding='0'><thead>"\r
+ for r=0 to LastHeadingRow\r
+ response.write vbLf & "<tr class='" & rows(r).HeadingClass & "'"\r
+ if r=ResizeRowIdx then response.write " id='" & id & "_tab0h_main'"\r
+ response.write ">"\r
+ response.write rows(r).HeadingRow(0,FrozenCols-1)\r
+ response.write vbLf & "</tr>"\r
+ next\r
+ response.write vbLf & "</thead></table>"\r
+\r
+ ' lower left\r
+ response.write "<table id='" & id & "_tab0' class='ricoLG_table ricoLG_bottom ricoLG_left' cellspacing='0' cellpadding='0'>"\r
+ response.write vbLf & "<tr>"\r
+ RenderColumns 0,FrozenCols-1\r
+ response.write vbLf & "</tr>"\r
+ response.write vbLf & "</table>"\r
+\r
+ response.write vbLf & "</div>"\r
+\r
+\r
+ '-------------------\r
+ ' scrolling columns\r
+ '-------------------\r
+\r
+ ' upper right\r
+ response.write vbLf & "<div id='" & id & "_innerDiv'>"\r
+ response.write vbLf & "<div id='" & id & "_scrollTabsDiv'>"\r
+ response.write vbLf & "<table id='" & id & "_tab1h' class='ricoLG_table ricoLG_top ricoLG_right' cellspacing='0' cellpadding='0'><thead>"\r
+ for r=0 to LastHeadingRow\r
+ response.write vbLf & "<tr class='" & rows(r).HeadingClass & "'"\r
+ if r=ResizeRowIdx then response.write " id='" & id & "_tab1h_main'"\r
+ response.write ">"\r
+ response.write rows(r).HeadingRow(FrozenCols,colcnt-1)\r
+ response.write vbLf & "</tr>"\r
+ next\r
+ response.write vbLf & "</thead></table>"\r
+ response.write vbLf & "</div>"\r
+ response.write vbLf & "</div>"\r
+\r
+ ' lower right\r
+ response.write vbLf & "<div id='" & id & "_scrollDiv'>"\r
+ response.write vbLf & "<table id='" & id & "_tab1' class='ricoLG_table ricoLG_bottom ricoLG_right' cellspacing='0' cellpadding='0'>"\r
+ response.write vbLf & "<tr>"\r
+ RenderColumns FrozenCols,colcnt-1\r
+ response.write vbLf & "</tr>"\r
+ response.write vbLf & "</table>"\r
+ response.write vbLf & "</div>"\r
+\r
+ response.write vbLf & "</div>"\r
+ End Sub\r
+end class\r
+\r
+%>\r