Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by James Snyder on Aug 12, 2009 11:42
open dhtmlx forum
Checkbox will not check via code

I have been working on setting a checkbox via Javascript but I keep getting the error: "_childIndexes is null or not an object" from dhtmlgrid.js, line 5685


The grid setup:
grdItems = new dhtmlXGridObject('grdItems_Container');
grdItems.setImagePath("../../images/grid_images/");
grdItems.imgURL = "../images/grid_images/";
grdItems.setHeader(",,");
grdItems.setNoHeader(true);
grdItems.enableColSpan(true);
grdItems.setInitWidths("200,150,20");
grdItems.setColAlign("left,right,right");
grdItems.setColTypes("ro,ro,ro");
grdItems.enableEditEvents(true);
grdItems.attachEvent("onCheckbox",addCost);
grdItems.init();

The checkbox is setup in this function:
function addItemExtra(objExtra) {
var iRow = (grdItems.getRowsNum()+1);
var mPrice = objExtra.Price;
grdItems.addRow(objExtra.ID,objExtra.Caption+','+mPrice);
grdItems.setCellExcellType(objExtra.ID,2,"ch");
}

These calls fail with the above stated error
grdItems.cells(3,2).setChecked(true);

or

grdItems.cells(3,2).setValue(true);

What am I doing wrong?

Thanks,
James
Answer posted by dhxSupport on Aug 13, 2009 07:36
cells(row_id, col) method has parameters:
row_id - row id
col - column index

So in your case you should use:
grdItems.cells(objExtra.ID,2).setChecked(true);
or
grdItems.cells(objExtra.ID,2).setValue(true);