2013-03-14 15 views

回答

6

此行不添加到dipslayed數據。

代碼添加到您fnDrawCallback添加一行在thead,或在您tbody的開頭:

var opts = {}; 

opts.fnDrawCallback = function(){ 
    var mySpecialRow = '<tr><td>First</td><td>Second</td></tr>'; 

    $('#mytable thead').append(mySpecialRow); 
    // or 
    $('#mytable tbody').prepend(mySpecialRow); 
} 
$('#mytable').dataTable(opts); 

也許我錯過了一些細節:

var $tr = $('#mytable tr.no-sort'); 
var mySpecialRow = $tr.html(); 
$tr.remove(); 

var opts = {}; 
opts.fnDrawCallback = function(){ 
    $('#mytable thead').append(mySpecialRow); 
    // or 
    $('#mytable tbody').prepend(mySpecialRow); 
}; 

// add any other option you want 
opts.sPaginationType = "full_numbers"; 

$('#mytable').dataTable(opts);  
+0

感謝提供這麼好的例如,但每當我正在做這個操作,它不會採取其他選項,如我需要使用「sPaginationType」:「full_numbers」選項,這是行不通的 – NARENDRA 2013-03-14 12:53:59

+0

你可以添加任何你喜歡的選項到'opts'對象 – LeGEC 2013-03-14 13:11:05

+0

非常感謝。 – NARENDRA 2013-03-14 13:26:41