【发布时间】:2018-03-11 05:58:09
【问题描述】:
我对 PHP 页面进行了以下 AJAX 调用,以从数据库中获取数据以将其显示在 HTML 页面的表中。我希望 #OrderTable 可以排序。
$.ajax({
type: "POST",
url: "searchorders.php",
data: {
'OrderBy': OrderBy,
'StartDate': startDate,
'EndDate': endDate
},
success: function(data) {
if (data == "Failed") {
$('#NoData').append("No data Found!");
} else {
$('#OrderTable').append(data);
document.getElementById("Results").style.display = 'block';
**$('#SearchResults').DataTable();**
}
}
})
我在 PHP 页面中的部分表格
$output.='<hr />
<table id="SearchResults" class="table table-striped table-bordered" style="width:auto;">
<thead>
<tr>
<th>Order No.</th>
<th>Customer Name</th>
<th>Order Date</th>
<th>Category Name</th>
<th>Category Type</th>
<th>Quantity in Kilos</th>
<th>Delivery Date</th>
<th>Order Status</th>
</tr>
</thead>
';
【问题讨论】:
-
获取记录排序并将返回的记录显示到表中
-
在你的
order by中使用SQL接收到的所有数据都会被排序。 -
我需要用户根据自己选择的实时时间列进行排序
-
查看数据表datatables.net
-
@DimitrisFilippou,我用过它,但它只显示箭头而没有排序,如果你能帮助我或者你以前用过它