function getText(c, r) {
var text = data[r][c];
if (text.length > 140) {
text = text.substring(0, 140);
}
return text;
}
grid.setCellText(getText);
obj.getCellTemplate(1).getContent("box/text").setAttribute("MAXLENGTH", 20);
var ukFormat = [
["aaa", "111", "21/02/2005", "", "A"],
["bbb", "22", "01/01/2004", "", "A"],
["bbb", "22", "10/11/2002", "", "B"] ,
["bbb", "22", "31/01/2003", "", "A"],
["bbb", "22", "31/01/2004", "", "B"]
];
var usFormat = [
["aaa", "111", "02-21-2005", true, "A"],
["bbb", "22", "01-01-2004", false, "A"],
["bbb", "22", "11-10-2002", false, "B"],
["bbb", "22", "01-31-2003", true, "A"],
["bbb", "22", "01-31-2004", true, "B"]
];
var string = new AW.Formats.String;
var number = new AW.Formats.Number;
var date = new AW.Formats.Date;
var obj = new AW.UI.Grid;
for (var i=0; i<ukFormat.length; i++){
var combo = new AW.UI.Combo;
combo.setItemText(["A","B"]);
combo.setItemCount(2);
obj.setCellTemplate(combo, 4, i);
}
obj.setCellTemplate(new AW.Templates.Checkbox, 3);
var template = new AW.Templates.Input
template.getContent("box/text").setAttribute("MAXLENGTH", 5);
obj.setCellTemplate(template, 0);
obj.getCellTemplate(1).getContent("box/text").setAttribute("MAXLENGTH", 5);
obj.setCellData(usFormat);
obj.setCellText(ukFormat);
obj.setCellFormat([string, number, date]);
obj.setColumnCount(ukFormat[0].length);
obj.setRowCount(ukFormat.length);
obj.setCellEditable(true);
obj.setSelectionMode("single-cell");
for(var i=0; i<obj.getRowCount(); i++){
obj.getRowTemplate(i).setStyle("background-color", function(){
return this.getRowProperty("mybackcolor");
});
}
obj.defineRowProperty("mybackcolor", function(row){
if (this.getCellData(4, row) == "A") {
return "red";
}
});
obj.setSize(600,300)
document.write(obj);
This topic is archived.