3

http://jsfiddle.net/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?

asked May 20, 2016 at 16:54

1 Answer 1

2

You 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.net/cmedina/c3coukLz/1/

Sebastianb
2,06024 silver badges31 bronze badges
answered May 20, 2016 at 17:28
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.