我使用的數據表jQuery插件,我期待做到以下幾點:數據表 - 數據跨3個表設置均勻 - 單一控制
我有一組數據,可以說350分的記錄。無論大小如何,我都希望以3個批次(或儘可能均勻)的方式提取記錄,並將它們顯示在一張紙上的3個表格中。應該沒有分頁。我想在一張桌子上排序,以便對其他人排序。
我試着根據數據庫中記錄的數量動態生成表格,然後創建一個for loop
。顯示由MySQL中的LIMIT
參數控制。問題是,如果表2應該顯示記錄51-100,我可以做到這一點,但它仍然顯示爲數據的一個子集:如果我點擊「按名稱排序」,它將按照參考其他200條記錄,並且不在其分配的範圍內。
是否有這樣做的更簡單的方法?以下是我已經試過:
jQuery.getJSON(TEMPLATEDIR + 「/includes/_shelf_record_check.php」 功能(數據){ shelfTotalRecords = data.total;
var recordsPerTable = 40;
var numberOfTables = Math.ceil(shelfTotalRecords/recordsPerTable);
for(var i=1; i<=numberOfTables; i++) {
if (i == 1)
var startRecord = 0;
else
var startRecord = ((i-1) * recordsPerTable);
jQuery.getJSON(templateDir + "/includes/_records_for_shelf_table.php?startRecord="+startRecord+"&recordsPerTable="+recordsPerTable, function(recordData) {
var shelfTable = "shelfTable"+i;
var HTMLTableID = 'shelf-table'+i;
jQuery('#shelf-table-page').append("<table id='"+HTMLTableID+"' class='display dataTable shelf'>" +
"<thead>" +
"<tr>"+
"<th></th>"+
"<th>Order</th>"+
"<th>First Name</th>"+
"<th>Last Name</th>"+
"<th>Shelf</th>"+
"<th>Status</th>"+
"</tr>"+
"</thead>"+
"<tbody>"+
"<tr>"+
"<td colspan='4' class='dataTables_empty'>Loading data from server</td>"+
"</tr>" +
"</tbody>"+
"<tfoot>"+
"<tr>"+
"<th></th>"+
"<th>Order</th>"+
"<th>First Name</th>"+
"<th>Last Name</th>"+
"<th>Shelf</th>"+
"<th>Status</th>"+
"</tr>"+
"</tfoot>" +
"</table>");
/* DataTable for the Shelf Table Page */
shelfTable = jQuery('#'+HTMLTableID).dataTable({
"bPaginate": false,
"iDisplayLength": recordsPerTable,
"iDisplayStart": startRecord,
"bProcessing": true,
"bServerSide": true,
"bDestroy": true,
"bJQueryUI": true,
"bFilter": false,
"bAutoWidth": false,
"oLanguage": {
"sInfoFiltered": " (_MAX_ total records)"
},
"bLengthChange": false,
"sAjaxSource": templateDir + "/includes/_get_shelf_table.php?recordIds="+recordData.recordIds,
"aaSorting": [[ 3, "asc" ]],
"aoColumns": [
{ "sName": "id", "bVisible": false },
{ "sName": "order_number"},
{ "sName": "first_name"},
{ "sName": "last_name"},
{ "sName": "shelf" },
{ "sName": "status_id" }
]
});
});
}
我嘗試了後面的建議,但無論什麼原因,在向每個查詢發送時都遇到了麻煩。我試圖將返回的JSON對象發送到_get_shelf_table.php腳本的URL中,但我認爲它的格式可能不正確,因爲它似乎沒有達到PHP腳本 – djt
我已更新我的代碼以反映該建議 – djt
我不知道你的API,但可能每張表的記錄不是正確的方法。它應該是像「endrecord」 – AwokeKnowing