我正在尝试使用DataTables和AJAX构建一个大型的交互式表(10,000个条目x 30列)。默认情况下,许多列都是隐藏的,但是AJAX请求仍然会加载数据。
是否可以只加载可见列中的数据?
一个简短的例子:
data_table = $('#table').DataTable({
"processing": true,
"serverSide": true,
"ajax": "http://127.0.0.1:8000/my/datatable/data/",
columnDefs: [
{title: 'Identifier', name: 'identifier', targets: [0]},
{title: 'Old Identifier', name: 'old_identifier', targets: [1], visible: false},
{title: 'Geographical Name', name: 'geographical_name', targets: [2], visible: false},
{title: 'Isolation Date', name: 'isolation_date', targets: [3], visible: false},
{title: 'Contaminated', name: 'contaminated', targets: [4], visible: false}
]
});
DataTables请求(针对隐藏的col 1进行了剪切):
columns[1][data]=1
columns[1][name]=old_identifier
columns[1][searchable]=true
columns[1][orderable]=true
columns[1][search][value]=
columns[1][search][regex]=false
返回的内容:
{"draw": 1, "recordsTotal": 8993, "recordsFiltered": 25, "data": [["xyz-1c-1i-1.1", "xyz", "Switzerland", "2019-06-13", "False"], ... ], "result": "ok"}