Server-side / multiply two columns and get value from function.
Server-side / multiply two columns and get value from function.
neurofunk
Posts: 14Questions: 5Answers: 1
Hello there,
(Based on this example: https://www.datatables.net/examples/server_side/row_details.html )
I've got two columns from database:
$columns = array(
array( 'db' => 'rate', 'dt' => 'episodes' ), // integer
array( 'db' => 'state' , 'dt' => 'length'), // integer
);
I want to multiply (episodes * length), then send it to the function:
function convert_minutes_to_string($minutes){
...
return $time_string; // eg. 2d 3h 12m
}
And get $time_string to my datatable
var dt = $('#example').DataTable({
....
"columns": [
{ "data" : "time_string" },
],
});
But I have no idea how to do that, anyone can help me?
This discussion has been closed.
Answers
Hi, @neurofunk.
I'm not a PHP programmer, but what I'm would do in Java is do the calculations on the server side and send the data to the front-end something like:
But I think you can also use the render options on the front-end to make the calculations, but I didn't test it yet.
Hope it helps.
Almir.
Unfortunately it doesn't work, but you inspired me and I found the solution:
But this solution makes next question:
How to make this column sortable by var total (by int)?