admin管理员组文章数量:1426950
/
t = $('#example').DataTable();
$('tbody tr').click(function() {
$(this).find('td:last').text('B');
//get back data
var tr = $(this);
var row = t.row(tr); // worked!
console.log(row.data()); // won't work
});
Everything seems to work but when I do row.data(), it got me back the old data before DOM manipulation. It seems like I have to somehow 'update' the datatable. How to manipulate column data programmatically using jquery?
http://jsfiddle/c3coukLz/
t = $('#example').DataTable();
$('tbody tr').click(function() {
$(this).find('td:last').text('B');
//get back data
var tr = $(this);
var row = t.row(tr); // worked!
console.log(row.data()); // won't work
});
Everything seems to work but when I do row.data(), it got me back the old data before DOM manipulation. It seems like I have to somehow 'update' the datatable. How to manipulate column data programmatically using jquery?
Share Improve this question asked May 20, 2016 at 16:54 Jamie JordanJamie Jordan 2511 gold badge5 silver badges16 bronze badges1 Answer
Reset to default 2You can use cell for altering data. indicate the row and column of the cell to modify. Use data
to assign the new value and draw
to refresh the table.
Try this code:
$('#example tbody').on( 'click', 'tr', function () {
//get back data
var row = t.row( this );
t.cell(row, 4).data("B").draw();
console.log(row.data());
});
Result: http://jsfiddle/cmedina/c3coukLz/1/
本文标签: javascriptdynamically change column data dataTablesStack Overflow
版权声明:本文标题:javascript - dynamically change column data dataTables - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745475240a2659933.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论