addClass / render / ajax.reload
addClass / render / ajax.reload
Romain974
Posts: 2Questions: 0Answers: 0
Hello,
I use API
when i load the page the first time my code works fine but when ajax.reload it deletes my addClass.
In my console everything in render is loaded twice.
setInterval( function () {
table.ajax.reload( null, false ); // user paging is not reset on reload
}, 30000 );
var table = $('#example').DataTable( {
"aaSorting": [[0,'desc']],
"paging": false,
ajax: "data.json",
// pageLength : 50 ,
dom: "Bfrtip",
ajax: {
url: "/api_table/controllers/join.php?date=<?php echo $datepost."&filtre=".$filtre; ?>",
type: 'POST'
},
serverSide: true,
columns: [
............................
{ data: "commande.attente", //status
render: function ( data, type, row, meta ) {
if (data == '1') {
console.log(row.DT_RowId); <<< this one is run 2 times
$( 'td', '#'+row.DT_RowId ).addClass( 'red' ); <<<< 1st time it works then no
Do you have an idea of the problem please?
This discussion has been closed.
Replies
You should use
columns.createdCellorcreatedRowfor this. If your data changes then userowCallbackinstead. These are intended for updating the HTML elements.columns.renderis not intended for this use.Kevin
Thank you kthorngren ! with rowCallback it works