Conditional grouping

Conditional grouping

berk bznberk bzn Posts: 1Questions: 1Answers: 0
edited June 2023 in Free community support

Hi.
I'm trying to create a BOM list. I grouped the table. It needs to be grouped in some rows. If 'Mont YMamül' in the column is 1, let it be the group. How can I do that or I can also get an alternative solution suggestion.

I want to make a table like this.

   $(document).ready(function () {
    var groupColumn = 0;
    var table = $('#example1').DataTable({
      columnDefs: [{ visible: false, targets: groupColumn }],
      displayLength: 10,
      ordering: false,
      drawCallback: function (settings) {
            var api = this.api();
            var rows = api.rows({ page: 'current' }).nodes();
            var last = null;
            api
                .column(groupColumn, { page: 'current' })
                .data()
                .each(function (group, i) {
                    if (last !== group) {
                        $(rows)
                            .eq(i)
                            .before('<tr class="group"><td colspan="8">' + group + '</td></tr>');
                        last = group;
                    }
                });
        },
    })
  });

Answers

Sign In or Register to comment.