2012-11-30 85 views
0

我一直在網絡上瀏覽數小時左右DataTables的保存滾動位置,但沒有任何運氣。至少不適合我的情況。DataTables保存狀態滾動位置

根據數據表,保存滾動條,我需要這行代碼的狀態:

$(document).ready(function() { 
    var oTable = $('#example').dataTable({ 
     "sScrollY": "200px", 
     "sAjaxSource": "media/data/2500.txt", 
     "sDom": "frtiS", 
     "bDeferRender": true, 
     "bStateSave": true 
    }); 
}); 

但是因爲我沒有用,我可以分析它不工作的數據的任何文本文件。我使用PHP和MYSQL獲取表中的數組。
"bStateSave": true確實保存了每個用戶輸入,例如過濾和排序,滾動條除外。

有誰知道如何解決這個問題?

編輯 好吧,我設法讓這個工作。看來我有些事情是真的,不應該這樣。現在,這個"sDom"滾動作品的saveState和,但我的GUI不見了......

編輯 我開始的代碼是:

<!-- DATATABLES ENABLE INIT --> 
<script> 
<?php include ('js/datatables/ordernumhtml.js');?> 
<?php include ('js/datatables/ordercurrency.js');?> 
<?php include ('js/datatables/dataTables.scroller.min.js');?> 
    $(document).ready(function() { 
     $('#table1').dataTable({ 
     "sDom": "frtiS", 
     "bDeferRender": false, 
     "bStateSave": true, 
     "bAutoWidth": true, 
     "bInfo": true, 
     "sScrollX": "100%", 
     "bScrollCollapse": true, 
     "bScrollAutoCss": true, 
     "bScrollInfinite": false, 
     "sScrollY": "350px", 
     "bJQueryUI": true, 
     "bProcessing": true, 
     "aoColumns": [ 
      { "sType": "num-html" }, 
      { "sType": "numeric" }, 
      null, 
      null, 
      null, 
      null, 
      null, 
      null, 
      { "sType": "currency" }, 
      null, 
      { "bSortable": false } 
     ]   
     }); 
    }); 
</script> 

回答

1

,將溶液重寫行:
"sDom": "frtiS",到:
"sDom": '<"H"fr>t<"F"iS>',

"H""F"表示頭和第頁腳e jQueryUI。

的sDOM用法的詳細描述可以在這裏找到:

http://datatables.net/usage/options#sDom

0

保存滾動狀態的解決方案是設置stateSave。爲了使這項工作還需要使用dataTables.scroller.js

$(document).ready(function() { 
$('#example').DataTable({ 
    ajax:   "data/2500.txt", 
    deferRender: true, 
    dom:   "frtiS", 
    scrollY:  200, 
    scrollCollapse: true, 
    stateSave:  true 
}); 

});

選中此項:Scroller State Saving