<html>
<head>
<title>ActiveWidgets Bug</title>
<script src="../runtime/lib/aw.js"></script>
<link href="../runtime/styles/xp/aw.css" rel="stylesheet"></link>
</head>
<body>
<style>
</style>
<span id="grid"></span>
<script>
var obj = new AW.UI.Grid;
obj.setId("grid");
obj.setHeaderText(["ID", "Description", "Total"]);
obj.setColumnCount(3);
obj.setCellEditable(true);
obj.setFooterCount(1);
obj.setFooterVisible(true);
obj.setFooterTemplate(new AW.Templates.Text, 2);
obj.setFooterText(function() { return "Total: " + mostraTotal(obj); }, 2);
obj.onCellEditEnded = function() {
obj.getFooterTemplate(2).refresh( );
}
obj.refresh( );
function mostraTotal( obj ) {
var tot = 0;
for(var i=0;i<obj.getRowCount();i++)
tot += Number(obj.getCellValue(2, i))
return tot;
}
var serial = 0;
function addRow() {
obj.addRow(serial++);
}
function delRow() {
if(obj.getCurrentRow() != -1) {
obj.deleteRow(obj.getCurrentRow());
obj.getFooterTemplate(2).refresh( );
}
}
</script>
<input type="button" value="addRow" onclick="addRow()" />
<input type="button" value="delRow" onclick="delRow()"/>
</body>
</html>
<html>
<head>
<title>ActiveWidgets Bug</title>
<script src="../runtime/lib/aw.js"></script>
<link href="../runtime/styles/xp/aw.css" rel="stylesheet"></link>
</head>
<body>
<style>
</style>
<span id="grid"></span>
<script>
var obj = new AW.UI.Grid;
obj.setId("grid");
obj.setHeaderText(["ID", "Description", "Total"]);
obj.setColumnCount(3);
obj.setCellEditable(true);
var data = [];
obj.setCellData(data);
obj.setFooterCount(1);
obj.setFooterVisible(true);
obj.setFooterTemplate(new AW.Templates.Text, 2);
obj.setFooterText(function() { return "Total: " + mostraTotal(obj); }, 2);
obj.onCellEditEnded = function() {
obj.getFooterTemplate(2).refresh( );
}
obj.refresh( );
function mostraTotal( obj ) {
var tot = 0;
for(var i=0;i<obj.getRowCount();i++)
tot += Number(obj.getCellValue(2, i))
return tot;
}
var serial = 0;
function addRow() {
data[data.length] = [data.length,2,3];
obj.addRow(data.length-1);
if (data.length == 1) {
obj.setCellData(data);
obj.refresh();
}
}
function delRow() {
if(obj.getCurrentRow() != -1) {
obj.deleteRow(obj.getCurrentRow());
obj.getFooterTemplate(2).refresh( );
}
}
</script>
<input type="button" value="addRow" onclick="addRow()" />
<input type="button" value="delRow" onclick="delRow()"/>
</body>
</html>
<html>
<head>
<title>ActiveWidgets Bug</title>
<script src="../runtime/lib/aw.js"></script>
<link href="../runtime/styles/xp/aw.css" rel="stylesheet"></link>
</head>
<body>
<style>
</style>
<span id="grid"></span>
<script>
var obj = new AW.UI.Grid;
obj.setId("grid");
obj.setHeaderText(["ID", "Description", "Total"]);
obj.setColumnCount(3);
obj.setCellEditable(true);
var data = [[]];
obj.setCellData(data);
obj.setFooterCount(1);
obj.setFooterVisible(true);
obj.setFooterTemplate(new AW.Templates.Text, 2);
obj.setFooterText(function() { return "Total: " + mostraTotal(obj); }, 2);
obj.onCellEditEnded = function() {
obj.getFooterTemplate(2).refresh( );
}
obj.refresh( );
function mostraTotal( obj ) {
var tot = 0;
for(var i=0;i<obj.getRowCount();i++)
tot += Number(obj.getCellValue(2, i)) // doenst work
// tot += Number(obj.getCellText(2, i)); // work
return tot;
}
var serial = 0;
function addRow() {
obj.addRow(serial++);
}
function delRow() {
if(obj.getCurrentRow() != -1) {
obj.deleteRow(obj.getCurrentRow());
obj.getFooterTemplate(2).refresh( );
}
}
</script>
<input type="button" value="addRow" onClick="addRow()" />
<input type="button" value="delRow" onClick="delRow()"/>
</body>
</html>
var first_row = data[0];
var first_row_cell = first_row[0];
This topic is archived.