如何更新数据表列中的数据

Tru*_*ran 1 jquery datatables

有人可以帮助我遍历数据表列中的所有行并更新其中的数据吗?到目前为止,我已经找到了一种遍历列的方法:

var table = $("#my_table").DataTable();
table.column(2)
    .data()
    .each(function(value, index) {
        console.log(value);
        value = 'abc123'; //this does not work
    });
Run Code Online (Sandbox Code Playgroud)

但是,我不确定如何更新该值.. 有人可以帮忙吗?

提前致谢!

dav*_*rad 7

column返回整个表的聚合数据。而是循环遍历行。有一个every()辅助函数可以让生活更轻松:

table.rows().every( function ( rowIdx, tableLoop, rowLoop ) {
   var data = this.data();
   data[2] += ' >> updated in loop' //append a string to every col #2
   this.data(data)
} )
Run Code Online (Sandbox Code Playgroud)

演示 -> http://jsfiddle.net/qx84jw55/