我正在使用带有 ASP.NET Gridview 的“DataTables Jquery”...
网格视图对于小型数据集非常有效,但对于大型数据集(> 5000 行),加载需要一些时间,并且在网格加载时加载圈也不会出现..
ASP.NET 伪代码 -
<body id="dt_example">
<form runat=server>
<asp:GridView ID="gv" runat="server" CellPadding="5" CellSpacing="5">
<RowStyle Wrap="False" />
</asp:GridView>
</form>
</body>
JavaScript -
<script type='text/javascript' charset='utf-8'>
$(document).ready(function () {
$('#gv').dataTable({
'bJQueryUI': true,
'sPaginationType': 'full_numbers',
'bAutoWidth': true
});
});
</script>
代码背后 -
protected void Page_Load(object sender, EventArgs e)
{
QueryRslt(passType, val);
gv.HeaderRow.TableSection = TableRowSection.TableHeader;
}
public void QueryRslt(string Type, string Value)
{
if (!string.IsNullOrEmpty(Type))
{
if (Type == "TaskStatus")
{
gv.DataSource = tsk
.Where(x => x.Status == Value)
.Select(m => new
{
ID = m.Incident_ID,
TaskID = m.Task_ID,
CI = m.CI,
Status = m.Status,
Priority = m.Priority,
ReportedDate = m.Task_Assign_Time,
AssigneeGroup = m.Assignee_Group,
AssignedGroup = m.Assigned_Group,
RespondDate = m.Incident_Responded_Date,
Reason = m.Status_Reason
}).ToList();
gv.DataBind();
}
else if (Type == "IncidentStatus")
{
gv.DataSource = inc
.Where(x => x.Status == Value)
.Select(m => new
{
ID = m.Incident_ID,
CI = m.CI,
Status = m.Status,
Priority = m.Priority,
ReportedDate = m.Incident_Reported_Date,
AssigneeGroup = m.Assignee,
AssignedGroup = m.Assigned_Group,
RespondDate = m.Incident_Responded_Date,
Reason = m.Status_Reason
}).ToList();
gv.DataBind();
}}}
加载的 Gif 出现了几分之一秒,然后消失了......
所以有两件事我想知道 -
显示加载 gif 直到整个 gridview 被填充..
减少处理数据的时间..