我的问题当我使用Databind
将数据填充到具有大量数据(超过2k行)的Gridview
时,会导致大量时间(5 - 10秒)并显示所有行在包装到分页之前
我发现Ajax的datatables
选项是deferrender
,我认为它可以解决我的问题,但是我不能将它用于databind
我尝试使用但没有可能< / p>
GridView的
<asp:GridView ID="GridView1" runat="server"
EnableViewState="false"
CssClass="table table-striped table-bordered jambo_table dt-responsive nowrap" Width="100%" CellSpacing="0"
DataSourceID="SqlDataSource2" AutoGenerateColumns="False" AllowPaging="false">
<Columns>
<asp:TemplateField HeaderText="No.">
HorizontalAlign="Center" Width="50px" />
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Container.DataItemIndex + 1 %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="TERM" HeaderText="Terminal" SortExpression="TERM">
<ItemStyle HorizontalAlign="Center" Width="150px" />
</asp:BoundField>
<asp:BoundField DataField="LOCATION" HeaderText="Location">
<ItemStyle HorizontalAlign="Left" />
</asp:BoundField>
<asp:BoundField DataField="RESPONSE" HeaderText="Response">
<ItemStyle HorizontalAlign="Center" Width="100px" />
</asp:BoundField>
<asp:BoundField DataField="EMV_FLAG" HeaderText="POS_ENTRY">
<ItemStyle HorizontalAlign="Center" Width="100px" />
</asp:BoundField>
<asp:BoundField DataField="TOTAL" HeaderText="Total"
SortExpression="TOTAL">
<ItemStyle HorizontalAlign="Center" Width="100px" />
</asp:BoundField>
</Columns>
<RowStyle CssClass="rowStyle" />
<HeaderStyle CssClass="headerStyle" />
<FooterStyle CssClass="footerStyle" />
<EmptyDataTemplate>
</EmptyDataTemplate>
</asp:GridView>
数据表
<script>
$(document).ready(function () {
$('#<%= GridView1.ClientID %>').GridviewFix({
header: "headerStyle",
row: "rowStyle",
footer: "footerStyle"
}).dataTable({
dom: "Bfrtip",
paging: true
, buttons: [
{
extend: "copy",
className: "btn-sm",
exportOptions: {
columns: [0, ':visible']
}
},
{
extend: "csv",
className: "btn-sm",
title: "Cash",
exportOptions: {
columns: ':visible'
}
},
{
extend: "excelHtml5",
className: "btn-sm",
exportOptions: {
columns: ':visible'
},
title: "Cash",
},
{
extend: "pdfHtml5",
className: "btn-sm",
title: "Cash",
orientation: 'landscape',
pageSize: 'A3'
},
{
extend: "print",
className: "btn-sm",
title: "Cash Status ",
},
],
columnDefs: [
{
targets: 0,
visible: false
}
],
responsive: true
});
});
</script>