2013-12-11 52 views
0

我正在使用數據表插件並希望通過單擊按鈕重新加載表列的排序。我正在更改桌面客戶端的內容。但是當我點擊redrawBtn時沒有任何反應。其他一切正常。數據表上的fndraw不起作用

// datatable config 
var oTable = tablesorterEl.dataTable({ 
"bPaginate": false, 
"bLengthChange": false, 
"bFilter": true, 
"bSort": true, 
"bInfo": false, 
"bAutoWidth": false, 
"bRetrieve": false, 
"asSorting": true, 
"bServerSide": false, 
"bSearchable": true, 
"aaSorting": [],      
"oLanguage": { 
"sSearch": "" 
}, 
"bStateSave": true 
}); 

// redraw button 
$('.redrawBtn').click(function(){ 

    oTable.fnDraw(); 
}); 

回答

2

如果你想讓fnDraw重新排序dataTable,你應該寫oTable.fnDraw(true)。

pietro

1

我發現我必須使用dataTables函數來操作dom。像

$('.redrawBtn').click(function(){ 
    oTable.fnUpdate('Example update', 0, 0); // Single cell. Will redraw by default 
}); 
+2

你可以接受你自己的答案,這樣人們可以看到問題是「封閉的」,也從你的解決方案中受益。 – davidkonrad