Footer into a datatable
Footer into a datatable
bobs64956
Posts: 18Questions: 6Answers: 0
pageTotal = api
.column( 2, { page: 'current'} )
.data()
.reduce( function (a, b) {
return intVal(a) + intVal(b);
}, 0 );
$( api.column( 2 ).footer() ).html(
'$'+pageTotal
);
$( api.column( 3 ).footer() ).html(
'$'+pageTotal*4
);
$( api.column( 4 ).footer() ).html(
'$'+pageTotal*52
);
sessionStorage.setItem("RandomVar", pageTotal); //This is to get the variable and output to another JS page
}
});
This above is just the footer of the column calcuations, it will be difficult to show my code in the template as its connected to a DB
ajax:{
url: "{{ route('test.index') }}",
data:{filter_ValueA:filter_ValueA, filter_ValueB:filter_ValueB}
},
columns: [
{
data:'ValueA',
},
{
data:'ValueB',
},
{
data:'ValueC',
},
This is how I normally output the code by getting the results from the DB. However, I want to use the variable of pageTotal and create a new row in a different page on a Datatable, is this possible?
This discussion has been closed.
Replies
We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.
Cheers,
Colin
Hey Colin,
It will be difficult to show the code as the code requires the DB to show the data.
The code is similar to this:
https://datatables.net/examples/advanced_init/footer_callback.html
I've put the value of the footer into a variable. I was wondering if there was a way to use that variable and create a new row within a new datatable?
The data doesn't matter really, it sounds like the problem is with creating the row, which we should be able to debug for you on http://live.datatables.net/
. We just need to see the problem you want help with,
Colin