How can I disable a checkbox in a grid?
I want to do this dynamically with JS - if there is a certain value, then disable a checkbox in a DataGrid.
many thanks
Max
many thanks
Max
Max Tomlinson
August 17,
<html>
<head>
<title></title>
<style>body {font: 12px Tahoma}</style>
<script src="../../runtime/lib/aw.js"></script>
<link href="../../runtime/styles/xp/aw.css" rel="stylesheet"></link>
<style>
#myGrid .aw-column-0 {width: 100px;}
#myGrid .aw-column-1 {width: 150px}
</style>
</head>
<body>
<span id="myGrid"></span>
<script>
var myData = [
[false, "unprotect"],
[false, "protect"],
[true, "unprotect"],
[true, "protect"]
];
MyCheckbox = AW.Templates.Checkbox.subclass();
MyCheckbox.create = function() {
var obj = this.prototype;
obj.setContent("box/text", "");
obj.setClass("disabled", function() {
if (this.$1 != null) {
if (this.$owner.getCellText(1, this.$1) == "protect") {
return "control";
}
}
return "";
});
obj.setEvent("onclick", function(event){
if (this.$1 != null) {
if (this.$owner.getCellText(1, this.$1) != "protect") {
var value = this.getControlProperty("value");
this.setControlProperty("value", !value);
}
}
});
}
var myHeaders = ["checkbox", "calue"];
var grid = new AW.UI.Grid;
grid.setId("myGrid");
grid.setHeaderText(myHeaders);
grid.setCellData(myData);
grid.setCellTemplate(new MyCheckbox, 0);
grid.setColumnCount(2);
grid.setRowCount(4);
grid.refresh();
</script>
</body>
</html>
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