:: Forum >>
checkBock with AW.XML.Table doesnt work
Hi all, first my english is not good.
Anybody know, why all checkbox are disable in this example?
Please help, this is a copy of an other example post it in this forum.
<html>
<head>
<link href="../../runtime/styles/xp/aw.css" rel="stylesheet" type="text/css" ></link>
<script src="../../runtime/lib/aw.js"></script>
</head>
<style>
.aw-alternate-even {
background: #2085d5;
}
.aw-alternate-odd {
background: #2095de;
}
.aw-grid-row {color: #ffffff; }
</style>
<body>
<input type=button value="See What's Checked" onClick="getChecked();"><br>
<script>
var table = new AW.XML.Table;
// provide data URL
table.setURL("../data/companies-simple.xml");
// start asyncronous data retrieval
table.request();
// define column labels
var columns = ["Ticker", "Company Name", "Market Cap.", "$ Sales", "Employees"];
var obj = new AW.UI.Grid;
obj.setControlSize(640, 480);
// provide column labels
obj.setHeaderText(columns);
obj.setColumnCount(5);
obj.setRowCount(40);
// enable row selectors
obj.setSelectorVisible(true);
obj.setSelectorText(function(i){return this.getRowPosition(i)});
obj.setSelectorWidth(25);
// set row selection
obj.setSelectionMode("single-row");
obj.onCellValueChanged = function(value, column, row){
window.status = "Cell " + column + "." + row + " changed to " + value;
}
// provide external model as a grid data source
// this is 'normal' checkbox
// it changes cell 'value', not selection
obj.setCellTemplate(new AW.Templates.Checkbox,0);
// set initial value for column 0
obj.setCellValue(true, 0);
// needed to get "checked" state
obj.setCellText(function(col, row){return this.getCellValue(col, row) ? "yes" : "no"}, 0);
obj.setCellModel(table);
document.write(obj);
function getChecked() {
for(var i=0;i<obj.getRowCount();i++) {
if(obj.getCellValue(0,i)) {
alert(i);
alert(obj.getCellValue(0,i));
}
}
}
</script>
</body>
</html>
This example with data in array work fine. Here is the example:
<html>
<head>
<link href="../../runtime/styles/xp/aw.css" rel="stylesheet" type="text/css" ></link>
<script src="../../runtime/lib/aw.js"></script>
</head>
<style>
.aw-alternate-even {
background: #2085d5;
}
.aw-alternate-odd {
background: #2095de;
}
.aw-grid-row {color: #ffffff; }
</style>
<body>
<input type=button value="See What's Checked" onClick="getChecked();"><br>
<script>
var myData = [["1","oid-1","function(col, row){return this.getCellValue(col, row) ? \"yes\" : \"no\"}","4","5","6","7","8","9","10"],
["1","oid-2","help","4","5","6","7","8","9","10"],
["1","oid-3","help","4","5","6","7","8","9","10"],
["1","oid-4","help","4","5","6","7","8","9","10"],
];
var obj = new AW.UI.Grid;
obj.setControlSize(640, 480);
// obj.setCellText(function(i, j){return j + "-" + i});
obj.setCellText(myData); // 2-dimensional js array // NEW LINE
obj.setHeaderText("header");
// provide column labels
obj.setColumnCount(5);
obj.setRowCount(5);
// enable row selectors
// set row selection
obj.setSelectionMode("single-row");
obj.onCellValueChanged = function(value, column, row){
window.status = "Cell " + column + "." + row + " changed to " + value;
}
// provide external model as a grid data source
// this is 'normal' checkbox
// it changes cell 'value', not selection
obj.setCellTemplate(new AW.Templates.Checkbox,0);
// set initial value for column 0
obj.setCellValue(true, 0);
// needed to get "checked" state
obj.setCellText(function(col, row){return this.getCellValue(col, row) ? "yes" : "no"}, 0);
document.write(obj);
function getChecked() {
for(var i=0;i<obj.getRowCount();i++) {
if(obj.getCellValue(0,i)) {
alert(i);
alert(obj.getCellValue(0,i));
}
}
}
</script>
</body>
</html>
Thanks in advance
/Juan
Thursday, December 22, 2005
I meet the same question too.
If you resolve it,pls post a new reply for these thread,thanks ! :)
Steven
Friday, June 23, 2006
This topic is archived.
Back to support forum
Forum search