2014-09-27 62 views
0

我想按降序排列記錄。 這裏我的代碼:Jquery datatables ::排序數據降序

的Jquery:

<script type="text/javascript" charset="utf-8"> 
var j = jQuery.noConflict(); 
j(document).ready(function() {`enter code here` 
    oTable = j('#example').dataTable({ 
     "bJQueryUI": true, 
     "sPaginationType": "full_numbers" 
    }); 
}); 
</script> 

我的SQL查詢:

$select="select * from users_tbl order by User_ID desc "; 

回答

1

這個屬性,如果你想訂購在第一降序排列的結果添加到您的表data-order='[[ 0, "desc" ]]'柱。

例子:

<table data-order='[[ 0, "desc" ]]' data-page-length='25'> 
    <thead> 
     <tr> 
      <th>ID</th> 
      <th>Name</th> 
      <th>Position</th> 
      <th>Office</th> 
      <th>Age</th> 
      <th>Start date</th> 
      <th data-class-name="priority">Salary</th> 
     </tr> 
    </thead> 
</table> 

會給你ID結果降序排列。就像數組一樣,0表示第一列,1表示第二列......等等。