Datatable automatic calculations using AJAX Question
Datatable automatic calculations using AJAX Question
bobs64956
Posts: 18Questions: 6Answers: 0
function fill_datatable(filter_supplier = '', filter_category = '')
{
var dataTable = $('#supplier_data').DataTable({
serverSide: true,
ajax:{
url: "{{ route('customsearch.index') }}",
data:{filter_supplier:filter_supplier, filter_category:filter_category}
},
columns: [
{
data:'suitemID',
name:'suitemID'
},
{
data:'suName',
name:'suName'
},
{
data:'suitemCostExGST',
name:'suitemCostExGST'
},
{
data:'suitemCostExGST' * 1.5, //What is the correct syntax on doing this calculation?
name:'suitemCostExGST'
},
]
});
}
suitemCostExGST is a column within the database. How can we do calculations of the data as we want the data of suitemCostExGST to be a multiple by 1.5.
Also, is there a way to create a new column with a button such as Edit/Delete button next to each record?
This question has accepted answers - jump to:
This discussion has been closed.
Answers
Use
columns.render
as a function.Here is an example:
http://live.datatables.net/xijecupo/1/edit
Kevin
Thanks
Another question,
From those buttons, is there a way to delete/edit the records in the DB by clicking on the buttons?
The example shows how to get the row clicked. You can either use the Editor for this process. Here is an example.
Or you can create your own functions to edit and delete the rows. You will then use Ajax to send the updates to your server script and it will need to perform the record deletions or updates.
Kevin