gpt4 book ai didi

php - 数据表 - 均匀分布在 3 个表中的数据 - 单个控件

转载 作者:行者123 更新时间:2023-11-30 01:12:26 25 4
gpt4 key购买 nike

我正在使用 Datatables JQuery 插件,并希望执行以下操作:

我有一组数据,假设有 350 条记录。无论大小如何,我都想分 3 个均匀批处理(或尽可能均匀)提取记录,并将它们显示在一页上的 3 个表中。不应该有分页。我想对一张表进行排序,以影响其他表的排序。

我尝试根据数据库中的记录数动态生成表,然后创建一个 for 循环。而显示是由MySQL中的LIMIT参数控制的。问题是,如果表 2 应该显示记录 51 - 100,我能够完成此操作,但它仍然将其显示为数据子集:例如,如果我点击“按名称排序”,它会按引用其他 200 条记录,但不在分配的 50 条记录之内。

是否有更简单的方法可以做到这一点?这是我尝试过的:

jQuery.getJSON( templateDir + "/includes/_shelf_record_check.php", function( data ) { 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" }
]

});
});
}

最佳答案

首先执行 for 循环将数据拆分为 3 个不同的数组,然后将这些单独的源传递给 jquery。或者我错过了什么?否则,如果您可以存储第一个结果的“id”,然后在每个查询中发送这些 id,。

关于php - 数据表 - 均匀分布在 3 个表中的数据 - 单个控件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19366875/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com