<html>
<head>
<link href="../../runtime/styles/xp/aw.css" rel="stylesheet" type="text/css" ></link>
<script src="../../runtime/lib/aw.js"></script>
<style>
.aw-grid-control {height: 150px; width: 100%; font: menu;}
</style>
</head>
<body>
<xml id="xmlDataIsland">
<companies>
<company>
<ticker>MSFT</ticker>
<name>Microsoft Corporation</name>
<mktcap>314571.156</mktcap>
<sales>32187.000</sales>
<employees>55000</employees>
</company>
<company>
<ticker>ORCL</ticker>
<name>Oracle Corporation</name>
<mktcap>62615.266</mktcap>
<sales>9519.000</sales>
<employees>40650</employees>
</company>
<company>
<ticker>SAP</ticker>
<name>SAP AG (ADR)</name>
<mktcap>40986.328</mktcap>
<sales>8296.420</sales>
<employees>28961</employees>
</company>
</companies>
</xml>
<script>
// create ActiveWidgets data model - XML-based table
var table = new AW.XML.Table;
// fix for format index bug in 2.0b1
table.getText = function(i, j){
var node = this.getNode(i, j);
var data = node ? node.text : "";
var format = this._formats[i];
return format ? format.dataToText(data) : data;
};
// create formatting object
var number = new AW.Formats.Number;
// configure formatting object
number.setTextFormat("$ #,###.#");
// assign format to data column
table.setFormat(number, 2);
// get reference to the xml data island node (IE only)
var xml = document.getElementById("xmlDataIsland");
// provide data XML
table.setXML(xml);
// define column labels
var columns = ["Ticker", "Company Name", "Market Cap.", "$ Sales", "Employees"];
// create ActiveWidgets Grid javascript object
var obj = new AW.UI.Grid;
// set number of rows, columns
obj.setColumnCount(5);
obj.setRowCount(3);
// provide column labels
obj.setHeaderText(columns);
// provide external model as a grid data source
obj.setCellModel(table);
// write grid html to the page
document.write(obj);
</script>
</body>
</html>
This topic is archived.