1
Hello, I have the following Json.
And I would like to show the Total value in a 'p', I am using the datatables to display the values of the "date". I am using the https://datatables.net/examples/api/row_details.html as an example. And to mount the table I use(just one example, mine is equal only with the data I wish):
$(document).ready(function() {
var table = $('#example').DataTable( {
"ajax": "../ajax/data/objects.txt",
"columns": [
{
"className": 'details-control',
"orderable": false,
"data": null,
"defaultContent": ''
},
{ "data": "name" },
{ "data": "position" },
{ "data": "office" },
{ "data": "salary" }
],
"order": [[1, 'asc']]
} );
// Add event listener for opening and closing details
$('#example tbody').on('click', 'td.details-control', function () {
var tr = $(this).closest('tr');
var row = table.row( tr );
if ( row.child.isShown() ) {
// This row is already open - close it
row.child.hide();
tr.removeClass('shown');
}
else {
// Open this row
row.child( format(row.data()) ).show();
tr.addClass('shown');
}
} );
Table html looks like this:
<table id="example" class="display" cellspacing="0" width="100%">
<thead>
<tr>
<th></th>
<th>Name</th>
<th>Position</th>
<th>Office</th>
<th>Salary</th>
</tr>
</thead></table>
I would like to add a p at the bottom of the table with this total value. But I don’t know how to create this. Thanks in advance.
When you say 'p' refers to the paragraph tag in HTML?
– Lucas Torres
Add where? And what would that 'p'?
– Yure Pereira
You want a total wage?
– Lucas Torres