Click here to Skip to main content
15,887,256 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a datatable having values

EPF value
123 100
123 10
123 700
143 40
143 30
145 40


I want the datatable as

EPF value
123 100
123 10
123 700
total 810

143 40
143 30
total 70

145 40
total 40


What I have tried:

JavaScript
function medical_claim_list_tables() {

        medical_claim_list_table = js('#medical_claim_list_table').DataTable({
            "destroy": true,
            "processing": true,
            "serverSide": true,
            "scrollX": false,
            language: {
                searchPlaceholder: "EPF No"
            },
            "ajax": {
                "url": site_url + "/Finance_balance_log_c/get_finance_balance_log",
                "type": "POST"
//                "data": function (d) {
//                    return js.extend({}, d, {
//                        "date_from": js('#date_from').val(),
//                        "date_to": js('#date_to').val(),
//                        "claim_category": js('#claim_category').val(),
//                        "claim_type": js('#claim_type').val(),
//                        "posted": posted
//                    });
//                }
            },

            "columns": [
                {"data": "emp_no"},
                {"data": "name_short"},
                {"data": "claim_type"},
                {"data": "claim_type_balance"}
            ],

            "lengthMenu": [[99999999], ["All"]],

            "createdRow": function (data, type, full, meta) {
                if(full['emp_no'])
                if (data[3].replace(/[\$,]/g, '') * 1 > 150000) {
                    js('td', row).eq(5).addClass('highlight');
                }
            }
Posted
Updated 12-Feb-18 9:59am
v2
Comments
Maciej Los 12-Feb-18 16:01pm    
You need to group data by EPF column. See: DataTables example - Row grouping[^]

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900