[英]How to get first row and append it to jQuery DataTables?
I'm getting my first row: 我正在第一行:
var lFirstRow = self.table.fnGetData($('#' + self.idResultGrid() + ' tbody tr:eq(0)')[0]);
And trying to append to my table: 并尝试追加到我的表:
$('#' + self.idResultGrid() + ' tbody').append(lFirstRow);
Doesn't work, any idea why? 不起作用,知道为什么吗?
Generally, you should avoid manipulating the table directly unless really necessary and use appropriate API methods. 通常,除非确实必要,否则应避免直接操作该表,并使用适当的API方法。
SOLUTION
解
Use fnAddData
(DataTables 1.9) or row.add()
(DataTables 1.10) to add data to the table: 使用
fnAddData
(DataTables 1.9)或row.add()
(DataTables 1.10)将数据添加到表中:
var lFirstRow = self.table.fnGetData($('#' + self.idResultGrid() + ' tbody tr:eq(0)'));
self.table.fnAddData(lFirstRow);
DEMO
演示
See this jsFiddle for code and demonstration. 有关代码和演示,请参见此jsFiddle 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.