:: Forum >>

Data Grid 2.0 Beta with ASP and xml Example

I just wanted to post a solution that I came up with that may be applicable to several other users. I am using an ASP Page to generate an xml structure, transforming it with xsl, and building a grid with it.

ASP Code:

Dim xml, xsl
Set xml = Server.CreateObject("MSXML2.DOMDocument")
Set xsl = Server.CreateObject("MSXML2.DOMDocument")

xml.async = False
xsl.async = False
rstData.Open strSQL, DataConn, adOpenStatic, adLockReadOnly, adCmdText
intRecCount = rstData.RecordCount
rstData.Save xml, 1 'adPersistXML

xsl.load Server.MapPath("z.xsl")

strXML = xml.transformNode(xsl)

Set xsl = Nothing
Set xml = Nothing

AW Code:
<xml id="xmlDataIsland">
<%=intRecCount%> Total Records
<script language="javascript">
var table = new AW.XML.Table;
// get reference to the xml data island node
var xml, node = document.getElementById("xmlDataIsland");
// IE
if (window.ActiveXObject){
xml = node;
// Mozilla
else {
xml = document.implementation.createDocument("","", null);

// provide data XML

// define column labels
var columns = ["Contract/Task", "Task Title", "Project Controller", "Tier Level", "Tool", "Lead Div." , "CRN", "Prime CAN", "Start Date", "End Date", "Contract Type", "Negotiated Value", "Funded Value", "EAC Revenue", "EAC Fee", "EAC Fee %", "EAC Date", "Prior EAC Fee %", "Prior EAC Date" , "Issues/Comments"];

// create ActiveWidgets Grid javascript object
var obj = new AW.Grid.Extended;

var obj = new AW.Grid.Extended; // create ActiveWidgets Grid javascript object
obj.setId("myGrid"); // not necessary unless more than one grid per page

<%If intRecCount < 20 Then%>
obj.setControlSize(screen.width - 75, (25 * <%=intRecCount%>) + 50);
obj.setControlSize(screen.width - 75, 500);
<%End If%>

obj.setColumnCount(20); //Number Of Columns to display
//Header Info
obj.setHeaderCount(1); // number of fixed header rows
obj.setHeaderText(columns); // provide column labels
obj.setFooterVisible(true); //Footer Info
obj.setFooterCount(1); //number of footer rows
obj.setFooterText(columns); // provide column labels
obj.setVirtualMode(true); //Virtual Mode
obj.setFixedLeft(1); // number of fixed columns on the left side
obj.setFixedRight(0); // number of fixed columns on the right side
obj.setSelectorVisible(true); //enable row selectors
obj.setSelectorText(function(i){return this.getRowPosition(i)});
obj.setSelectionMode("single-row"); // set row selection
obj.setCellModel(table); // provide external model as a grid data source
document.write(obj); // write grid html to the page



<?xml version="1.0" encoding="iso-8859-1" ?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882" xmlns:z="#RowsetSchema">
<s:Schema id="RowsetSchema"/>
<xsl:output method="xml" omit-xml-declaration="yes" />

<xsl:template match="/">
<xsl:apply-templates select="//z:row"/>

<xsl:template match="z:row">
<xsl:text disable-output-escaping="yes">&lt;row&gt;</xsl:text>
<xsl:for-each select="@*">

<xsl:text disable-output-escaping="yes">&lt;</xsl:text>
<xsl:value-of select="name()"/>

<xsl:text disable-output-escaping="yes">&gt;</xsl:text>
<xsl:value-of select="."/>

<xsl:text disable-output-escaping="yes">&lt;/</xsl:text>
<xsl:value-of select="name()"/>

<xsl:text disable-output-escaping="yes">&gt;</xsl:text>
<xsl:text disable-output-escaping="yes">&lt;/row&gt;</xsl:text>


this a simple way to use xml to produce large grids with very little processing overhead.

If anybody out there knows how to help me format my xsl stylesheet to dynamically detect column datatypes and format or mask them accordingly I would love it.
I would like to specify a specific date format and convert currency data to include the appropriate punctuation. So instead of 311.3
i will output $311.30 to the grid.
Jim Shaffer
Friday, October 21, 2005

This topic is archived.

Back to support forum

Forum search