📜  jquery 数据表更新行单元格值 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:01.703000             🧑  作者: Mango

代码示例1
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])  
     }                                                                              
});