0
我需要能夠運行Jquery函數來更新某個單元格中的值。查找並更新DataTable中的單元格
表中的每一行有一列中唯一的ID號
<table id="example">
<thead>
<tr>
<th>
ID
</th>
<th>
Count
</th>
</tr>
</thead>
<tfoot>
<tr>
<th>
ID
</th>
<th>
Count
</th>
</tr>
</tfoot>
<tbody>
<tr>
<td>
<%= a.id %>
</td>
<td>
<%= a.count %>
</td>
</tr>
</tbody>
</table>
我需要使用jQuery或東西更新右表中的行a.count
「無需重新加載頁面」具有id
是匹配的計數爲a.id
此表將有許多行。
------------編輯-------------
我怎麼可以用這個類添加到計數單元以及
var addId = $('#<%= @table %>').dataTable().fnAddData(<%= @post %>);
var theNode = $('#<%= @table %>').dataTable().fnSettings().aoData[addId[0]].nTr;
theNode.setAttribute('id','<%= @id %>');
解決我這樣做:
var addId = $('#<%= @table %>').dataTable().fnAddData(<%= @post %>);
var theNode = $('#<%= @table %>').dataTable().fnSettings().aoData[addId[0]];
theNode.nTr.setAttribute('id','<%= @id %>');
theNode.anCells[1].setAttribute('class', 'count');
我能做到這與數據表的jQuery – 2015-03-24 21:43:01
是的,你需要做的,無論你是真正建立表格行 - 無論是在軌道視圖或JavaScript。 – Matt 2015-03-24 21:45:29
如何將該類添加到計數單元格中?我正在使用這個在表格已經繪製之後添加行...(請參閱編輯) – 2015-03-25 14:12:33