// clear row model
obj.setRowProperty("value", function(i){return i});
obj.setRowProperty("order", function(i){return i});
obj.setRowProperty("count", myData.length);
// clear selection model
obj.setSelectionProperty("index", -1);
// clear sort model
obj.setSortProperty("index", -1);
obj.setSortProperty("direction", "none");
obj.refresh();
<html>
<head>
<link href="../../runtime/styles/xp/grid.css" rel="stylesheet" type="text/css" ></link>
<script src="../../runtime/lib/grid.js"></script>
<style>
.active-controls-grid {height: 120px; border: 1px solid #ccc; font: menu;}
</style>
<script>
var myData1 = [
["MSFT","Microsoft Corporation", "314,571.156", "32,187.000", "55000"],
["ORCL", "Oracle Corporation", "62,615.266", "9,519.000", "40650"],
["SAP", "SAP AG (ADR)", "40,986.328", "8,296.420", "28961"],
["CA", "Computer Associates Inter", "15,606.335", "3,164.000", "16000"],
["ERTS", "Electronic Arts Inc.", "14,490.895", "2,503.727", "4000"]
];
var myData2 = [
["SFTBF", "Softbank Corp. (ADR)", "14,485.840", ".000", "6865"],
["VRTS", "Veritas Software Corp.", "14,444.272", "1,578.658", "5647"],
["SYMC", "Symantec Corporation", "9,932.483", "1,482.029", "4300"]
];
var myColumns = [
"Ticker", "Company Name", "Market Cap.", "$ Sales", "Employees"
];
</script>
</head>
<body>
<button onclick="setNewData(myData1)">Dataset 1</button>
<button onclick="setNewData(myData2)">Dataset 2</button>
<script>
var myData = myData1;
var obj = new Active.Controls.Grid;
obj.setRowProperty("count", myData.length);
obj.setColumnProperty("count", 5);
obj.setDataProperty("text", function(i, j){return myData[i][j]});
obj.setColumnProperty("text", function(i){return myColumns[i]});
document.write(obj);
function setNewData(dataArray){
myData = dataArray;
// clear row model
obj.setRowProperty("value", function(i){return i});
obj.setRowProperty("order", function(i){return i});
obj.setRowProperty("count", myData.length);
// clear selection model
obj.setSelectionProperty("index", -1);
// clear sort model
obj.setSortProperty("index", -1);
obj.setSortProperty("direction", "none");
obj.refresh();
}
</script>
</body>
</html>
// fixing 'response' method
Active.HTTP.Request.prototype.response = function(){
var obj = this.$owner;
if (!obj) {return}
// clear row model
obj.setRowProperty("value", function(i){return i});
obj.setRowProperty("order", function(i){return i});
obj.setRowProperty("count", this.getCount());
// clear selection model
obj.setSelectionProperty("index", -1);
// clear sort model
obj.setSortProperty("index", -1);
obj.setSortProperty("direction", "none");
obj.refresh();
}
<html>
<head>
<link href="../../runtime/styles/classic/grid.css" rel="stylesheet" type="text/css" ></link>
<script src="../../runtime/lib/grid.js"></script>
<style>
.active-controls-grid {height: 200px; font: menu;}
</style>
</head>
<body>
<button onclick="newData('list1.xml')">Dataset 1</button>
<button onclick="newData('list2.xml')">Dataset 2</button>
<script>
// fixing 'response' method
Active.HTTP.Request.prototype.response = function(){
var obj = this.$owner;
if (!obj) {return}
// clear row model
obj.setRowProperty("value", function(i){return i});
obj.setRowProperty("order", function(i){return i});
obj.setRowProperty("count", this.getCount());
// clear selection model
obj.setSelectionProperty("index", -1);
// clear sort model
obj.setSortProperty("index", -1);
obj.setSortProperty("direction", "none");
obj.refresh();
}
var columns = ["Ticker", "Company Name", "Market Cap.", "$ Sales", "Employees"];
var table = new Active.XML.Table;
table.setURL("list1.xml");
table.request();
var obj = new Active.Controls.Grid;
obj.setColumnProperty("texts", columns);
obj.setDataModel(table);
document.write(obj);
function newData(URL){
table.setURL(URL);
table.request();
}
</script>
</body>
</html>
/*
** Fills the specified grid with the specified XML string.
*/
function doPopulateGrid (oGrid, sXML, bDeferRefresh) {
// Create ActiveWidgets data model - XML-based table
var table = new Active.XML.Table;
// Provide data XML
table.setXML (sXML);
// Provide external model as a grid data source
oGrid.setDataModel (table);
if (!bDeferRefresh)
oGrid.refresh ();
}
function dataGrid_paging_setNewData(oDatagrid, aDatagridData)
{
obj = oDatagrid;
myData = aDatagridData;
alert(myData);
//clear row model
obj.setProperty("row/value", function(i){return i});
obj.setProperty("row/order", function(i){return i});
obj.setProperty("row/count", myData.length);
//clear selection model
obj.setSelectionProperty("index", -1);
// re-initialize the row values
var newCount = obj.getProperty("row/count");
var rowValues = [];
for(var i=0; i < newCount; ++i)
{
rowValues[i] = i;
}
obj.setRowProperty("values", rowValues);
//clear sort model
obj.setSortProperty("index", -1);
obj.setSortProperty("direction", "none");
obj.refresh();
}
This topic is archived.