Example - saving editable grid data to the server
Here is a simplified example how one can save changes in editable grid to the server. The code sends the modified cells to the server cell-by-cell using onCellValidated event. To finish it you have to implement updateSingleCell.php or .asp or whatever server-side code which will actually save the data. The server-side script is called via POST method with three arguments (column, row, text).
In reality you probably want to send data row-by-row and do some validation, but still this example should give an idea where to start.
<html>
<head>
<script src="../../runtime/lib/aw.js"></script>
<link href="../../runtime/styles/xp/aw.css" rel="stylesheet"></link>
</head>
<body>
<script>
var myCells = [
["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"]
];
var myHeaders = [
"Ticker", "Company Name", "Market Cap.", "$ Sales", "Employees"
];
var obj = new AW.UI.Grid;
obj.setCellText(myCells);
obj.setHeaderText(myHeaders);
obj.setColumnCount(5);
obj.setRowCount(3);
obj.setCellEditable(true);
obj.onCellValidated = function(text, column, row){
var r = new AW.HTTP.Request;
r.setURL("updateSingleCell.php");
r.setRequestMethod("POST");
r.setParameter("column", column);
r.setParameter("row", row);
r.setParameter("text", text);
r.request();
r.response = function(data){
alert(data); // process response data
}
}
document.write(obj);
</script>
</body>
</html>
In reality you probably want to send data row-by-row and do some validation, but still this example should give an idea where to start.
Alex (ActiveWidgets)
February 28,