3.2.0

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
Max Tomlinson
August 17,
Disabling individual cells is not possible yet in AW 2.0.2 - so far 'disabled' property is only implemented for the control itself.
Alex (ActiveWidgets)
August 20,
The template in the example disables the checkbox
<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>
Bryn
August 20,

This topic is archived.

See also:


Back to support forum