:: Forum >> Version 2 >>

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
Friday, August 17, 2007
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)
Monday, August 20, 2007
The template in the example disables the checkbox
<html>
<
head>
    <
title></title>
    <
style>body {font12px Tahoma}</style>
    <
script src="../../runtime/lib/aw.js"></script>
    <
link href="../../runtime/styles/xp/aw.css" rel="stylesheet"></link>
<
style>
    
#myGrid .aw-column-{width100px;}
    
#myGrid .aw-column-{width150px}
</
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.$!= null) {
            if (
this.$owner.getCellText(1this.$1) == "protect") {
                return 
"control";
            }
        }
        return 
"";
    });
    
obj.setEvent("onclick", function(event){
        if (
this.$!= null) {
            if (
this.$owner.getCellText(1this.$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 MyCheckbox0);
grid.setColumnCount(2);
grid.setRowCount(4);
grid.refresh();
</
script>
</
body>
</
html
Bryn
Monday, August 20, 2007



This topic is archived.

Back to support forum

Forum search