Trying to make use of jquery dataTable plugin for my application but i have an issue with it. If the table has two records, it shows the two records on the table and then shows "Showing 1 to 1 of 1 entries" . Also, i want to export the content to excel or copy to clipboard. It only copies or export just one row. For example , if my dataTable has four rows, it only copy just one row and i get to see "Showing 1 to 1 of 1 entries" at the footer
What I have tried:
$(document).ready(function () {
$('#ex').dataTable({
destroy: true,
ordering: true,
responsive: true,
"paging": true,
"bAutoWidth": false,
"searching": true,
dom: 'Bfrtip',
buttons: [
'copyHtml5',
'excelHtml5',
'csvHtml5',
'pdfHtml5'
]
});
;
});
</script>
i have also added the following flies to it. Note: i'm using it in my asp.net application.
<script src="<%: ResolveUrl("plugins/datatables/jquery-3.2.1.js")%>"></script>
<script src="<%: ResolveUrl("plugins/jQueryUI/jquery-ui.js")%>"></script>
<script src="<%: ResolveUrl("plugins/datatables/jquery.dataTables.min.js")%>"></script>
<link href="<%: ResolveUrl("plugins/datatables/jquery.dataTables.min.css")%>" rel="stylesheet" />
<link href="<%: ResolveUrl("plugins/datatables/button.dataTables.min.css")%>" rel="stylesheet" />
<link href="<%: ResolveUrl("plugins/datatables/responsive.dataTables.min.css")%>" rel="stylesheet" />
<script src="<%: ResolveUrl("plugins/datatables/dataTables.responsive.min.js")%>"></script>
<script src="<%: ResolveUrl("plugins/datatables/dataTables.bootstrap.js")%>"></script>
<script src="<%: ResolveUrl("plugins/datatables/dataTables.buttons.min.js")%>"></script>
<script src= "<%: ResolveUrl("plugins/datatables/buttons.flash.min.js")%>"></script>
<script src="<%: ResolveUrl("plugins/datatables/jszip.min.js")%>"></script>
<script src="<%: ResolveUrl("plugins/datatables/pdfmake.min.js")%>"></script>
<script src="<%: ResolveUrl("plugins/datatables/vfs_fonts.js")%>"></script>
<script src= "<%: ResolveUrl("plugins/datatables/buttons.html5.min.js")%>"></script>
<script src="<%: ResolveUrl("plugins/datatables/buttons.print.min.js")%>"></script>
private void GenerateExcel(int coopId)
{
var coopmembers = coop.CoopMembers.Where(m => m.CoopId == coopId).ToList();
var loanApplication = coop.LoanApplications.Where(m => m.LoanStatus == "Running").ToList();
var query = (from c in coopmembers
join l in loanApplication on c.Member_Id equals l.MemeberId
select new
{
c.SubscriberCode,
c.FirstName,
c.LastName,
c.MiddleName,
l.ApplicationId,
l.MonthDeduction,
}).ToList();
Repeater.DataSource = query;
Repeater.DataBind();
}
protected void Page_Load(object sender, EventArgs e)
{
int coopid = Convert.ToInt32(Session["CoopId"]);
GenerateExcel(coopid);
}