2014-11-14 59 views
0

我在我的django項目中使用jQuery數據表插件與服務器端處理。如何禁用表初始化排序

我想顯示從mysql數據庫到jquery數據表的最新插入記錄。目前,當我重新加載頁面時,默認情況下表格數據按照第一列的升序進行排序。我不想要這個。有沒有辦法顯示數據,因爲它是在頁面加載時從服務器發送的?稍後,點擊一個列的排序應該爲各自的colummn完成。我怎樣才能做到這一點?任何幫助?

回答

0

使用此,並嘗試:

$(document).ready(function() { 
$('#example').dataTable({ 
    "order": [] 
}); 

});

看一看這個https://datatables.net/reference/option/order

+0

aaSoring:[]是不是爲我工作 –

+0

不過它在默認情況下在遞增順序排序的第一列 –

0
here is sample code to initialize data table plugin 

    var oTable = $('.datatable').dataTable({ 
         "sPaginationType": "full_numbers", 
         "bJQueryUI": false, 
         "sDom": '<"H">t<"F"ip>', 
         "aLengthMenu": [[10, 25, 50, 100, -1], [10, 25, 50, 100, "All"]], 
         "iDisplayLength": 10, 
         "aaSorting": [[0, 'desc']], 
         "oLanguage": { "oPaginate": { "sNext": '>', "sLast": '>>', "sFirst": '<<', "sPrevious": '<'} }      
        }); 


in above initialization we have to remove "aaSorting" paramater. 


    var oTable = $('.datatable').dataTable({ 
         "sPaginationType": "full_numbers", 
         "bJQueryUI": false, 
         "sDom": '<"H">t<"F"ip>', 
         "aLengthMenu": [[10, 25, 50, 100, -1], [10, 25, 50, 100, "All"]], 
         "iDisplayLength": 10, 
         "oLanguage": { "oPaginate": { "sNext": '>', "sLast": '>>', "sFirst": '<<', "sPrevious": '<'} }      
        });