Sto usando la tabella dati. Voglio sommare alcune colonne e voglio mostrarle in fondo al rapporto. Cerco molte cose. Poi ho trovato la nuova funzione di callback footer nella tabella dati. L'ho usato. Ma ancora la mia uscita non è ancora pronto ..come sommare alcune righe in dataTable utilizzando footercallback
Il mio codice come segue,
function Databind(Pdestroy) {debugger;
var destroy = false;
if (Pdestroy == "1")
destroy = true;
var oTable = $('.datatable').dataTable({
"bJQueryUI": true,
'bServerSide': true,
"bDestroy": destroy,
"iDisplayLength": 10,
"sPaginationType": "full_numbers",
'sAjaxSource': '<%= Url.Action("listcount", "Home") %>',
"bFilter": true,
"aoColumnDefs": [{ 'bSortable': false, 'aTargets': [0, 1, 2, 7, 8, 9, 10, 11]}],
"fnRowCallback": function (nRow, aData, iDisplayIndex) {
var oSettings = oTable.fnSettings();
$("td:first", nRow).html(oSettings._iDisplayStart + iDisplayIndex + 1);
return nRow;
},
"footerCallback": function (row, aData, start, end, iDisplayIndex) {
var api = this.api(),
data;
// 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
total = api.column(4)
.data()
.reduce(function (a, b) {
return intVal(a) + intVal(b);
});
// Total over this page
pageTotal = api.column(4, {
page: 'current'
})
.data()
.reduce(function (a, b) {
return intVal(a) + intVal(b);
}, 0);
// Update footer
$(api.column(5).footer()).html(
'$' + pageTotal + ' ($' + total + ' total)');
}
});
}
Qui sta mostrando undefined.And anche non c'è che mostra l'errore. Ma l'output non viene mostrato. Ho attaccato la schermata di uscita ..
per ottenere i valori che cosa devo fare processo futher?
mostrando nCells [1] .innerHTML = parseInt (iTarget); 'impossibile impostare la proprietà innerHTML di undefined' – PoliDev
possibili ragioni sono 1.non hai definito tfoot 2. non hai definito th the tfoot. @PoliDev –