Set input limit for grid row?
I need to limit the input length of a row in the grid to 140 chars, there is only one column, any way to do this? Thanks.
Rajeem
March 3,
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.
ActiveWidgets is a javascript library for creating user interfaces. It offers excellent performance for complex screens while staying simple, compact and easy to learn. Deployed by thousands of commercial customers in more than 70 countries worldwide.
Copyright © ActiveWidgets 2021