checkbox select row

Hi,

I’m using a grid with a master_checkbox, and when I click a button, i want to send the value of the selected rows to a function.

So, i have my grid:
mygrid = new dhtmlXGridObject(‘gridbox’);
mygrid.setImagePath(“common/imgs/”);
mygrid.setHeader(“A,B,C,D);
mygrid.attachHeader(”#master_checkbox,#text_filter,#text_filter,#numeric_filter");
mygrid.setInitWidths(“40,150,100,100”);
mygrid.setColTypes(“ch,ro,ro,ro”);
mygrid.setColSorting(“na,str,str,int”);
mygrid.forEachRow(function(id){
var cell=mygrid.cells(id,0);
if (cell.isCheckbox()) cell.setValue(1);
});
mygrid.init();
mygrid.enableSmartRendering(true, 50);
mygrid.setSkin(“dhx_blue”);
mygrid.loadXML(“Recodification.do”);

A button:

The function invoked when clicking the button:
function ajaxFunction() {
if(xmlhttp) {
xmlhttp.open(“POST”,“Recod2.do”,false);
xmlhttp.onreadystatechange = handleServerResponse;
xmlhttp.setRequestHeader(‘Content-Type’, ‘application/x-www-form-urlencoded’);
xmlhttp.send();
}
}

In this function, i have the rowid of the selected rows using the API:
mygrid.getCheckedRows(0)

But i want to have the text of the column B, which is not the checkbox row. How can I do this? Thanks

You can get value of cell in column B with following code:

var value=mygrid.cellById(rowId,cellIndex).getValue();

Hi Olga,

thanks for the reply, but I only want to have the value of the column B of the selected rows to send it to a servlet. Something like this:

xmlhttp.send(“ID=” + mygrid.getCheckedRows(0) + “&B=” + mygrid.cellById(21,cellIndex).getValue());

You can get id of selected row with getSelectedRowId() method

docs.dhtmlx.com/doku.php?id=dhtm … ectedrowid

Thanks Olga,

but mygrid.getSelectedRowId();

returns allways null, even when checked some rows. What could cause this behaviour?

Regards.

This method returns id of selected row, no id of checked row

Thanks,

Eduardo.