Hi, I’ve got the following code and my checkbox acts like a readonly or disabled box, but if I remove the entire event of “onEditCell,” my checkbox works and will update. But then I can’t edit my other cell. Leaving both events in there, only the “onEditCell” works. How can I get both of them working?
services_grid.attachEvent(“onEditCell”, function(stage,rowId,cellInd,newValue,oldValue){
if (stage == 2 && cellInd == 2) {
var rowId_arr = rowId.split("");
dhtmlxAjax.get("…/ajax/set_service.php?link=true&id="+rowId_arr[2]+"&field=transit&value="+newValue, function(loader){
if (loader.xmlDoc.responseText) { alert(loader.xmlDoc.responseText); }
});
return true;
}
});
services_grid.attachEvent(“onCheckbox”, function(rowId,cellInd,state){
var rowId_arr = rowId.split("");
var state_num = 0 + state;
dhtmlxAjax.get("…/ajax/set_service.php?id="+rowId_arr[1]+"&field=is_active&value="+state_num, function(loader){
if (loader.xmlDoc.responseText) { alert(loader.xmlDoc.responseText); }
});
});
in your code:
services_grid.attachEvent(“onEditCell”, function(stage,rowId,cellInd,newValue,oldValue){
if (stage == 2 && cellInd == 2) {
…
return true;
}
// if the column index is not a “2” the event return false, so the edit operation blocks.
// you need to return true to a column with checkbox.
});
Hi, Sorry, I’m performing 2 different Events. onEditCell is to make changes in column 2 which is just column type: ed. Whereas onCheckbox is to make changes in column 3 which is just column type: ch
How do I get both onEditCell for column 2 and onCheckbox for column 3 to both work?
you need to return true to a column with checkbox in onEditCell event to allow checking of the checkbox.
For example:
services_grid.attachEvent("onEditCell", function(stage,rowId,cellInd,newValue,oldValue){
if (stage == 2 && cellInd == 2) {
var rowId_arr = rowId.split("_");
dhtmlxAjax.get("../ajax/set_service.php?link=true&id="+rowId_arr[2]+"&field=transit&value="+newValue, function(loader){
if (loader.xmlDoc.responseText) { alert(loader.xmlDoc.responseText); }
});
return true;
}
if (cellInd == 3) return true // add this line
});
Thank you. Works perfectly now.