2016-07-29 43 views
0

我有HTML表格数据表multible列排序不行

<table id="example" class="display" cellspacing="0" width="100%"> 
    <thead><tr><th>Name</th><th>Address</th><th>Phone</th><th>Email</th></tr></thead> 
    <tfoot><tr><th>Name</th><th>Address</th><th>Phone</th><th>Email</th></tr></tfoot> 
</table> 

和jQuery从datatables.net

$('#example').DataTable({ 
    "processing": true, 
    "serverSide": true, 
    "orderMulti": true, 
    "aaSorting": [ [0,'asc'], [1,'asc'] ], 
    "ajax": { 
     url: "data.php", 
     "type": "POST" 
    } 
}).fnSort([ [0,'asc'], [1,'asc'] ]); 

而且问题blugin是,如何把多个工作表中的排序。如果我点击我点击地址表单击。我想点击地址标题改变它的排序并保持名称排序。但点击一张桌子,其他排序正在失去。查看图片。在按名称desc的sql查询顺序中,地址asc从不起作用。 谢谢 enter image description here

回答

0

你的服务器端排序启用:https://datatables.net/examples/server_side/

你实际上做服务器端的任何排序?

+0

是服务器网站。 – user2301515

+0

我需要查看从服务器发回的json数据。请参阅服务器端处理文档。它需要在一定的格式, –

+0

echo jsonEncode(DB :: query(“SELECT name,city,phonenumber,contactEmail FROM mytable ORDER BY phonenumber asc LIMIT 0,100”)); 我想在点击事件查询部分“顺序phonenumber asc,城市desc,名称asc”不仅“按名称顺序排序”。但可能数据表js-blugin无法启用它。 – user2301515