add-delete-row example - deleteRow()
In the examples/new/add-delete-row example, the deleteRow function doesn't appear to actually work. The original example is based on a function rather than on actual data, but changing it to actual data shows the problem:
When you click "add row", it adds a new row to the grid display, and also to the javascript array.
When you edit a row, e.g. change "2" to "2 bananas", this is reflected in the javascript array.
However, when you delete a row, it deletes the selected row from the display but does *not* delete the row from the data array.
Is the example given missing something, or does deleteRow(i) just not work in the same manner way as addRow()?
<html>
<head>
<title>ActiveWidgets Examples</title>
<script src="../../runtime/lib/aw.js"></script>
<link href="../../runtime/styles/xp/aw.css" rel="stylesheet"></link>
</head>
<body>
<style>
</style>
<script>
var obj = new AW.UI.Grid;
var data = Array();
data.push([1,11,111]);
data.push([2,22,222]);
data.push([3,33,333]);
// row index
var serial = data.length;
obj.setSize(300, 150);
obj.setCellText(data);
obj.setHeaderText(["a","bb","ccc"]);
obj.setColumnCount(3);
obj.setRowCount(data.length);
obj.setCellEditable(true);
document.write(obj);
obj.onRowAdded = function(row){
window.status = "Row added: " + row;
this.setCellText([serial,serial+''+serial,serial+''+serial+''+serial], row);
}
obj.onRowDeleting = function(row){
return !confirm("Delete row " + row + "?");
}
obj.onRowDeleted = function(row){
window.status = "Row deleted: " + row;
}
function add(){
obj.addRow(serial++);
}
function del(){
var i = obj.getCurrentRow();
obj.deleteRow(i);
}
function show(){
var sTemp = '[\n';
for (var i=0;i<data.length;i++)
{
sTemp += ' ['+data[i][0]+','+data[i][1]+','+data[i][2]+']\n';
}
sTemp += ']';
alert(sTemp);
}
</script>
<br>
<button onclick="add()">add row</button>
<button onclick="del()">delete row</button>
<button onClick="show()">show array contents</button>
</body>
</html>
When you click "add row", it adds a new row to the grid display, and also to the javascript array.
When you edit a row, e.g. change "2" to "2 bananas", this is reflected in the javascript array.
However, when you delete a row, it deletes the selected row from the display but does *not* delete the row from the data array.
Is the example given missing something, or does deleteRow(i) just not work in the same manner way as addRow()?
Robin
September 21,