data load issue
data load issue
var editor; // use a global for the submit and return data rendering in the examples
http://debug.datatables.net/ecegac
$(document).ready(function() {
editor = new $.fn.dataTable.Editor( {
ajax: "../php/gets.php",
table: "#example",
fields: [ {
label: "id:",
name: "loans.id"
}
]
} );
var table = $('#example').DataTable({
"dom": "Tfrtip",
"ajax": "../php/gets.php",
"columns": [
{
"title": "Loan ID",
"data": "loans.id",
"visible": false
}, {
"title": "UUID",
"data": "loans.uuid"
}, {
"title": "Branch",
"data": "annualtargets.Branch",
"sortable": false
}, {
"title": "Month",
"data": "annualtargets.Month",
"sortable": false
}, {
"title": "Year",
"data": "annualtargets.Year",
"sortable": false
}, {
"title": "BusinessLoanNumber",
"data": "annualtargets.BusinessLoanNumber",
"sortable": false
}, {
"title": "BusinessLoanAmount",
"data": "annualtargets.BusinessLoanAmount",
"sortable": false
}, {
"title": "RetailLoanNumber",
"data": "annualtargets.RetailLoanNumber",
"sortable": false
}, {
"title": "RetailLoanAmount",
"data": "annualtargets.RetailLoanAmount",
"sortable": false
}
],
"drawCallback": function (settings) {
var api = this.api();
var rows = api.rows({
page: 'current'
}).nodes();
var last = null;
api.column(0, {
page: 'current'
}).data().each(function (group, i) {
if (last !== group) {
$(rows).eq(i).before(
$("<tr></tr>", {
"class": "group",
"data-id": group
}).append($("<td></td>", {
"colspan": 5,
"class": "pocell",
"text": "Loan ID " + group
})).append($("<td></td>", {
"id": "e" + group,
"class": "noCount",
"text": "0.00"
})).append($("<td></td>", {
"id": "p" + group,
"class": "noCount",
"text": "0.00"
})).append($("<td></td>", {
"id": "b" + group,
"class": "noCount",
"text": "0.00"
})).prop('outerHTML'));
last = group;
}
val = api.row(api.row($(rows).eq(i)).index()).data();
$("#e" + val.loans.id).text(parseFloat($("#e" + val.loans.id).text()) + parseFloat(val.annualtargets.BusinessLoanAmount));
$("#p" + val.loans.id).text(parseFloat($("#p" + val.loans.id).text()) + parseFloat(val.annualtargets.RetailLoanNumber));
$("#b" + val.loans.id).text(parseFloat($("#b" + val.loans.id).text()) + parseFloat(val.annualtargets.RetailLoanAmount));
});
},
"footerCallback": function (row, data, start, end, display) {
var api = this.api();
$(api.column(6).footer()).html(
api.column(6).data().reduce(function (a, b) {
return parseFloat(a) + parseFloat(b);
})
);
$(api.column(7).footer()).html(
api.column(7).data().reduce(function (a, b) {
return parseFloat(a) + parseFloat(b);
})
);
$(api.column(8).footer()).html(
api.column(8).data().reduce(function (a, b) {
return parseFloat(a) + parseFloat(b);
})
);
}
});
});
This question has accepted answers - jump to:
This discussion has been closed.
Answers
got that solved ->
I'm not sure what the question was, but good to hear you have it fixed now.
Allan