Datatables automatically getting the sum of the column and displaying it using AJAX.

Datatables automatically getting the sum of the column and displaying it using AJAX.

bobs64956bobs64956 Posts: 18Questions: 6Answers: 0
function fill_datatable(filter_supplier = '', filter_category = '')
    {
        var dataTable = $('#supplier_data').DataTable({

            serverSide: true,
            ajax:{
                url: "{{ route('companycost.index') }}",
                data:{filter_supplier:filter_supplier, filter_category:filter_category}
            },
            columns: [
                {
                    data:'suitemID',
                    name:'suitemID'
                },
                {
                    data:'suName',
                    name:'suName'
                },
                {
                    data:'suitemBrand',
                    name:'suitemBrand'

                },
                {
                    data:'suitemCostExGST', //Want to get the total amount of this column and display it in a new row
                    name:'suitemCostExGST'
                },
                {
                    defaultContent: '<input type="button" class="Edit" value="Edit"/><input type="button" class="Delete" value="Delete"/>'
                },
            ]
        });
    }

Getting the value of suitemCostExGST from the DB. I want to get the sum of all the value in the column and display it in a new row

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 20,144Questions: 26Answers: 4,736
    Answer ✓

    Take a look at the FooterCallback Example.

    Kevin

  • bobs64956bobs64956 Posts: 18Questions: 6Answers: 0

    Is there a way to store the value of that and pass it to a different page?

    E.g: I want the total value of the variable suitemCostExGST and use it in another datatable

This discussion has been closed.