我使用的数据表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