3.2.0

Checkboxes Doubleclick Problem

Hi,

We have a checkbox in a grid. The user has to click the checkbox twice to activate it. How can I change the behaviour, so that the first click on the checkbox will activate it?

Here the important code:
var myCellData = [
["142","false","Geologe"],
["143","true","Mathe-Genie"],
["144","true","Mathe-Genie"],
["146","false","Mathematiker"]
];
grid.setCellTemplate(new AW.Templates.CheckBox,1);

Here other behaviour:
- When checkboxes are selected (a value of true in the datagrid when page is rendered), then a single click will work.
- When the user has already selected a checkbox and deselected it agian, then a single click will work.

Thanks a log for your answers
Claude
November 17,
Claude
Alex posted a Checkbox Template example here:
http://www.activewidgets.com/javascript.forum.9440.11/checkbox-example.html

To make your code fit Alex's sample just need to add your array :
obj.setCellText( myCellData );
and adjust Rowcount to 4 and ColumnCount to 3
and replace the line:
obj.setCellValue(false, 2);
with this one :
obj.setCellValue(function(i, j){return i==1)? eval(myCellData[j][i]):''});


Note : the 'eval' is because the true/false values in your array are between doublequote (") and are considered text, but no need of (eval command) if the array contain boolean values like:
var myCellData = [["142",false,"Geologe"],["143",true,"Mathe...
In that case you can also use obj.setCellValue( myCellData ) to convert all array texts to values.
HTH

Carlos
November 17,
Sorry , also need to replace the '2' with an '1' in this lines:
obj.setCellTemplate(new AW.Templates.Checkbox, 2);
obj.setCellText(function(col, row){return this.getCellValue(col, row) ? "yes" : "no"}, 2);
if(obj.getCellValue(2,i)) {
November 17,
Thanks a lot for your answer. It worked! The method grid.setCellValue() solved the double clicked problem :)

Here a sample:
<script>
var myCellData = [
["142","false","Geologe","Olten","08/12/2008 01:00:00","12/12/2008 01:00:00","","100000141"],
["143","true","Mathe-Genie","Olten","08/12/2008 01:00:00","12/12/2008 01:00:00","","100000142"],
["144","true","Mathe-Genie","Olten","08/12/2008 01:00:00","12/12/2008 01:00:00","","100000143"],
["146","false","Mathematiker","Olten","08/12/2008 01:00:00","12/12/2008 01:00:00","","100000145"]
];
var myHeaderText  = ["link","","Stellenbezeichnung","Arbeitsort","Anmeldedatum","Bewerbung bis","Inaktivdatum","Stellen-Nr"];
var string = new AW.Formats.String;
var stringCb = new AW.Formats.String;
stringCb.dataToText = function(data){ return ""; };
var number = new AW.Formats.Number;
var date = new AW.Formats.Date;
date.setDataFormat("ISO8601")
date.setTextFormat("dd.mm.yyyy");
date.setErrorText("");
var myCellFormats  = [string,stringCb,string,string,date,date,date,string];
var grid = new AW.UI.Grid;
grid.setId("myGrid");
grid.setCellData(myCellData);
grid.setHeaderText(myHeaderText);
grid.setCellFormat(myCellFormats);
grid.setRowCount(4);
grid.setColumnCount(8);
grid.onCellClicked=function(event, column, row){

selectOste(row, myCellData[row]);

 return;
};
grid.setCellTemplate(new AW.Templates.CheckBox,1);

grid.setCellValue(
    function(i, j){	
        if(i != 1){
            return false;
        }		
        var myflag = myCellData[j][i];
        if("true" == myflag){
            return true;
        }
        return false;
    }
); 
grid.refresh();
</script>



Claude
November 18,

This topic is archived.

See also:


Back to support forum