1

I have a datatable in which I would like to apply row grouping to it. Also included is a checkbox plugin. I've tried the code listed on the datatables website, but I had no luck. The api doesn't add the row for the grouping for the "City" column. The code I used for the grouping is shown below:

$(document).ready(function (){
          $('#example').DataTable({
            columnDefs: [{
                targets: 0,
                'checkboxes': {
                    'selectRow': true
                }
            },
            { "visible": false, "targets": 1 }],
            select: {
                style: 'multi'
            },
            order: [[1, 'asc']],
            iDisplayLength: 10,
            drawCallBack: function () {
                var api = this.api();
                var rows = api.rows({ page: 'current' }).nodes();
                var last = null;

                api.column(1, { page: 'current' }).data().each(function (group, i) {
                    if (last !== group) {
                        $(rows).eq(i).before(
                            '<tr class="group"><td colspan="6">' + group + '</td></tr>'
                        );

                        last = group;
                    }
                });
            }
        });
});

I have the code in my jfiddle here. Could the checkbox be interfering with the grouping? Please let me know where I am going wrong.

Note: The checkbox is based on the plugin by gyrocode The datatables is version 1.10.12

1 Answer 1

2

You're using incorrect option name, should be drawCallback and not drawCallBack.

See updated example for code and demonstration.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.