I'm doing an AJAX request which returns an Id. The idea is to update my datatable without reloading the page. I get the row index perfectly. And set the row class perfectly. But now I want to set some values in some cells of that row. And I can't get it. It says 'table.cell is not a function'. Here's my code:
$.ajax({
url: "trasladosDespacharGuardar.php",
success: function(result) {
id = parseInt(result);
var index = table.fnFindCellRowIndexes( id, 1 );
var row = table.api().row(index).node();
$(row).addClass('warning');
//Up to this point , everything is perfect
var cell = table.cell(index,5);
cell.data('Helloo');
}
});
In order to use cell
the way as suggested in OP, use the { row, column }
selector and finalize with draw()
:
table.cell({ row: index, column: 5 }).data('Helloo').draw();
Regarding 'table.cell is not a function', the dataTable is probably not initialized with DataTable()
, capital D
. If there is a reason for initializing with dataTable() we still have access to the API by api()
:
table.api().cell({ row: index, column: 5 }).data('Helloo').draw();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With