Check corresponding checkbox in another column when checkbox in one column is checked.

Check corresponding checkbox in another column when checkbox in one column is checked.

sklskl Posts: 1Questions: 1Answers: 0

Hi,

I have created a datatable using AJAX data. the table has two columns of checkboxes created as below -

,
{
data: "Message",
render: function ( data, type, row ) {
if ( type === 'display' ) {
return '<input class="checkbox1" type="checkbox" name="cb" value="' + data + '">';
}
//console.log( 'Row index: '+ row( this ).index() );
return data;
}
},
{
data: "Component",
render: function ( data, type, row ) {
if ( type === 'display' ) {
return '<input class="checkbox1" type="checkbox" name="cb_component" value="' + data + '">';
}
return data;
}
}

The column with Component data needs to be hidden. Once user checks any checkbox in Message column, the corresponding checkbox in Componenet should also get checked so that form can send that data back to the back end.

How can this be achieved?

I am trying to set id of the checkboxes based on the row index and get those on the click event. but I cannot get either of them working.

//console.log( 'Row index: '+ row( this ).index() ); - returns -1

and the debugger does not seem to hit the click event either :(

Thanks.
SKL

This discussion has been closed.