Datatable automatic calculations using AJAX Question

Datatable automatic calculations using AJAX Question

bobs64956bobs64956 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:

Answers

  • kthorngrenkthorngren Posts: 10,638Questions: 25Answers: 2,428
    Answer ✓

    How can we do calculations of the data as we want the data of suitemCostExGST to be a multiple by 1.5.

    Use columns.render as a function.

    is there a way to create a new column with a button such as Edit/Delete button next to each record?

    Here is an example:
    http://live.datatables.net/xijecupo/1/edit

    Kevin

  • bobs64956bobs64956 Posts: 18Questions: 6Answers: 0
    edited September 11

    Thanks :)

  • bobs64956bobs64956 Posts: 18Questions: 6Answers: 0

    Another question,

    From those buttons, is there a way to delete/edit the records in the DB by clicking on the buttons?

  • kthorngrenkthorngren Posts: 10,638Questions: 25Answers: 2,428
    Answer ✓

    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

Sign In or Register to comment.