Updating the value of a single cell in DataTables
Updating the value of a single cell in DataTables
Hi all. I've been struggling with the issue of updating the value of a cell in DataTables. I have a column that I initialize properly when the table is first loaded using the render to execute a function.
But, then some event takes place, and I need to update the value of that cell in certain rows. This is where I'm struggling. I've done a bunch of google searches related to what I am attempting, and nothing I have tried works completely. I feel like I am close. I am able to select the cell contents using this (the variable table holds a reference to the DataTable):
$(table.cell({row: table_idx, column: 9}).node()).html()
Then, I run a similar command to set the contents of that cell:
$(table.cell({row: table_idx, column: 9}).node()).html("Data to be displayed")
After issuing that command, I check the value of the cell using the first command above, and I get back the new string I'm attempting to set it to. But, the value on the page is still showing the original value. I was told you need to redraw the table, but I've tried numerous ways of redrawing the table to no effect.
So, if someone can point me in the right direction, I would greatly appreciate.
Thanks,
Tony
Answers
Hi abruno1974,
since you already have the table reference, it should be fairly simple to do.
Take a look at the examples on this reference page:
draw()
Use
cell().data()
to update a cell's content.Allan