jQuery DataTables-根据行ID更改特定单元格中的数据 [英] Jquery DataTables - Change Data in Specific Cell Based on Row ID
问题描述
我试图通过转到特定的表行ID来更改Jquery DataTable中第5列的表数据.默认情况下,我所有的表行的ID均为row<id number>
.例如:
I'm trying to change the 5th column's table data in my Jquery DataTable, by going to the specific table row ID. By default, all of my table rows have an id of row<id number>
. For example:
<tr id="row147">
<td>147</td>
...
要尝试更改特定的表数据单元格,我尝试了类似的操作
To attempt to change a specific table data cell, I tried something like this
table.row("#row" + data.job_id).data(variable).draw()
但是这会在每个表数据单元的整个行中写入数据.如何在行中指定表数据单元格,然后使用DataTables API将其写入其中?
But this writes data across the entire row in each table data cell. How do I specify the table data cell within the row and just have it write in that with the DataTables API?
推荐答案
I ended up finding a solution by following this post here. Basically have to give every <td>
an ID. Then I can use table.cell('#td_5_' + data.job_id).data(variable)
to write in the new data to a specific cell.
这篇关于jQuery DataTables-根据行ID更改特定单元格中的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!