Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

jquery datatable update row cell value

let msg = { id: 1, customer_name: 'Fred' };  // source of updates (from backend)
let row = table.row('#row-' + msg.id);
let rowindex = row.index();                                                            
let columns = table.settings().init().columns;                                      
table.columns().every(function (colindex) {     
     let coldata = columns[colindex].data;  // 'data' as in the DT column definition
     if (coldata != 'id' && msg.hasOwnProperty(coldata)) {  // (don't update the id!)
         table.cell({row: rowindex, column: colindex}).data(msg[coldata])  
     }                                                                              
});
 
PREVIOUS NEXT
Tagged: #jquery #datatable #update #row #cell
ADD COMMENT
Topic
Name
6+2 =