How should i have dropdown , file exporters and sum in all for one datatable.
How should i have dropdown , file exporters and sum in all for one datatable.
nareshkumarcsg
Posts: 2Questions: 1Answers: 0
$(document).ready(function () {
$('#<%=GridView1.ClientID%>').DataTable({
"footerCallback": function (row, data, start, end, display) {
var api = this.api();
// Remove the formatting to get integer data for summation
var intVal = function (i) {
return typeof i === 'string' ?
i.replace(/[\$,]/g, '') * 1 :
typeof i === 'number' ?
i : 0;
};
// Total over all pages
total6 = api
.column(6)
.data()
.reduce(function (c, d) {
return intVal(c) + intVal(d);
}, 0);
pageTotal6 = api
.column(6, { page: 'current' })
.data()
.reduce(function (c, d) {
return intVal(c) + intVal(d);
}, 0);
$(api.column(6).footer()).html(
'Current/Total : ' + pageTotal6 + '/' + total6
);
total = api
.column(7)
.data()
.reduce(function (a, b) {
return intVal(a) + intVal(b);
}, 0);
// Total over this page
pageTotal = api
.column(7, { page: 'current' })
.data()
.reduce(function (a, b) {
return intVal(a) + intVal(b);
}, 0);
// Update footer
$(api.column(7).footer()).html(
'Current/Total : ' + pageTotal + '/' + total
);
}
});
});
$(document).ready(function () {
$('#<%=GridView1.ClientID%>').DataTable({
dom: 'Bfrtip',
buttons: [
'copy', 'csv', 'excel', 'pdf', 'print'
]
});
});
Answers
also this has to be added for dropdowns
$('#<%=GridView1.ClientID%>').DataTable({
You need to combine the elements into the one initialisation object, so something like:
Colin