Change data value to order table
Change data value to order table
ritaalamino
Posts: 2Questions: 1Answers: 0
I am trying to change the value of the cell using
table.row(tr).data on click; but I can't find how I am able to do that.
$('#cautela_table tbody').on('click', 'td.star-control', function () {
var tr = $(this).closest('tr');
var row = table.row(tr);
var cotista_id = row.data().cotista__id;
var status = row.data().favorito;
atualizaStatus(cotista_id, !status);
if (status == true) {
atualizaStatus(cotista_id, false);
row.node().cells[0].innerHTML = '<i class="far fa-star"></i>';
} else {
atualizaStatus(cotista_id, true);
row.node().cells[0].innerHTML = '<i class="fas fa-star"></i>';
}
I already did this, but I want to change the internal value so the person doesn't have to reload the page.
Can you help me?
This question has an accepted answers - jump to answer
Answers
This example is showing how to
cell().data()
, the same principles would apply forrow().data()
. Could you look at that, please, and see if it helps. If it's still not working for you, please can you update my example, or link to your page, so that we can see the problem.Cheers,
Colin
I have done it! But i have a new problem, after I change the value, the ordering filter is not working to the recently changed cell. Is there something I am forgetting?
row().data()
is both a getter and a setter. You need to pass the updated data as a parameter torow().data()
to use it as a setter. Something like this:Kevin