我一直在尝试使用HTML和jquery Datatable插件编写2万多行数据。我编写的功能运行正常,但至少可以正常工作。在搜索如何使其更快地加载时,我看到了deferRender
,所以我现在就在上面,它不起作用,不知道我缺少什么。
设计
<div id="ItemListTable" class="table-responsive m-t-40">
<table id="ITEMTable" style="width: 100%" class="table table-bordered table-striped">
<thead>
<tr>
<th>Id</th>
<th>Item Code</th>
<th>Item Name</th>
</tr>
</thead>
</table>
</div>
jQuery
$(document).ready(function () {
try {
$('#ITEMTable').DataTable({
"processing": true,"serverSide": true,"deferRender": true,"ajax": {
"url": Apiurl + "ItemRegType_Api","type": "POST","data": JSON.stringify({ BranchId: ('<%= Session["BranchId"] %>'),CategoryType: "ITMGP",flag: "SELECTALL" }),"contentType": "application/json","dataType": "json","success": function (data) {
return data.data.Table;
},"error": function (error) {
jsonValue = jQuery.parseJSON(error.responseText);
},"failure": function (response) {
alert("Error");
}
}
});
}
catch (err) {
ErrorMsgsToast("Table load : " + err.message);
}
});
Ajax结果:
{
"data": {
"Table": [
{
"id": 436,"Code": "PL","Name": "PLASTIC"
},{
"id": 499,"Code": "OL","Name": "OPALWERE"
},{
"id": 516,"Code": "SE","Name": "STONE"
}
]
}
}
我得到一个没有任何错误错误的空表。如何处理datatable上的大量数据?请帮助