I have a jquery datatable when the user selects the checkbox I want it to transfer the data to the new table
However when I click to row the the data is transferred to the other table I want the row data to be transferred only when the checkbox is checked. Thank you for your help.
$("#tblProveedorToTransfert").on('click', 'tr', function (e) {
var $row = primaryTable.row(this).data(); //Gets row of main table
secondTable.row.add($row).draw(); //Add row to another table
});
Add here is my table
var primaryTable = $('#tblProveedorToTransfert').DataTable({
rowId: 'compras_id',
"ajax": {
"url": "/compra/loadCompraTableForProveedor",
"traditional": true,
"type": "GET",
"datatype": "json",
"data": function (data) {
data.idProveedor = @id;
}
},
"columns": [
{
"width": "40px", "render": function (data, type, row) { /* index = 0 */
return '';
}
},
{
"width": "10px", "render": function (data, type, row) { /* index = 0 */
return '<input value="0" type="checkbox" class="checkbox" name="comprasIds" id="comprasIds" data-id="' + row.compras_id + '" />';
}
},
{ "data": "nombre_proveedor", "autoWidth": true }, /* index = 0 */
{ "data": "numero_contrato", "autoWidth": true }, /* index = 1 */
{ "data": "numero_pedido", "autoWidth": true }, /* index = 2 */
{ "data": "marca", "autoWidth": true }, /* index = 3 */
],
});
});
How can i change my code so that the data is only transferred when the check button is clicked.