我有一个报告数据表。当我试图显示我的数据时,我的浏览器冻结或崩溃。我的js代码在下面
Reporting_Report.DTReport = $('#Report-ReportTable').DataTable({
"ajax": {
"url": "/Ajax/JsonProvider?Method=HardwareHostScreenUsage&GenericObject=true&Json=" + JSON.stringify(json),
"dataSrc": ""
},
"columns": [
{
"data": "BranchName",
"sTitle": "BranchName"
},
{
"data": "HardwareHostFriendlyName",
"sTitle": "Hardware Host Friendly Name"
},
{
"data": "HardwareHostScreenUsageScreenState",
"defaultContent": "N/A",
"sTitle": "Hardware Host Screen Name"
"render": function(data, type, full) {
if (data && Util.Check.IsInteger(data)) {
if (data == 1) {
return "Sorry Screen";
} else if (data == 2) {
return "Welcome Screen";
} else if (data == 3) {
return "Progress Screen";
}
}
}
},
{
"data": "HardwareHostScreenUsageSecondOnScreen",
"sTitle": "Elapsed Time On Hardware Host Screen"
},
{
"data": "HardwareHostScreenUsageRecordDate",
"sTitle": "Hardware Host Screen Usage Record Date"
"render": function (data, type, full) {
return Util.JsonDateToDate(data).format("dd.mm.yyyy HH:MM:ss");
}
}
],
"pageLength": 20,
"lengthMenu": [
[20, 50, 100, -1],
[20, 50, 100, "All"]
],
"info": false,
bFilter: true,
bInfo: false,
"order": [[0, "asc"]],
"scrollX": true,
dom: 'Bfrtip',
buttons: [
{
extend: 'copy'
},
{
extend: 'csv'
},
{
extend: 'excel'
},
{
extend: 'pdf',
title: "Detailed Ticket Report"
message: startDate + " " + startTime + " - " + endDate + " " + endTime + "\t" + datetime,
pageSize: 'LEGAL'
},
{
extend: 'print'
}
]
});
我有超过100.000个数据。
我想也许我可以只显示页面数据和总数据编号(用于管理页码),当点击另一个页码时发送新查询并获取新数据。但我无法找到如何做到这一点。(也许它会引起另一些问题(短路,搜索vs。)
您有任何想法和解决方案。(或者这个问题已经有了解决方案)
脚注:json有一些查询过滤器(时间,分支等)
HardwareHostScreenUsage方法在c#侧获取我的数据。
答案 0 :(得分:0)
您也可以使用客户端数据源 -
var mydata = [];
$('#example').DataTable({
data: data,
deferRender: true,
scrollY: 200,
scrollCollapse: true,
scroller: true
});
从服务器一次获取所有数据,并在滚动表格时显示它。
你需要这些库 -
https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js https://cdn.datatables.net/scroller/1.4.3/js/dataTables.scroller.min.js