Creating rows child in a server-side processing datatable

Creating rows child in a server-side processing datatable

MrJibusMrJibus Posts: 4Questions: 1Answers: 0
edited January 2023 in Free community support

I am using datatable with server side. When the datatable is complete, child rows are added :

        initComplete: function () {
          this.api().rows().every(function (rowIdx, tableLoop, rowLoop) {
            var data = this.data();
            if (data.message) {
              this
                .child(
                  $(
                    '<tr>' +
                    '<td><b>Message</b> : ' + data.message + '</td>' +
                    '<td></td>' +
                    '<td></td>' +
                    '<td></td>' +
                    '<td></td>' +
                    '<td></td>' +
                    '<td></td>' +
                    '<td></td>' +
                    '</tr>'
                  )
                )
                .show();
            }
          });

Problem : since i am using server side with pagination. On page 2, message are not displayed beacause initComplete is only fire once.

Solution : using another event like drawcallback.

        drawCallback: function () {
          this.api().rows().every(function (rowIdx, tableLoop, rowLoop) {
            var data = this.data();
            if (data.message) {
              this
                .child(
                  $(
                    '<tr>' +
                    '<td><b>Message</b> : ' + data.message + '</td>' +
                    '<td></td>' +
                    '<td></td>' +
                    '<td></td>' +
                    '<td></td>' +
                    '<td></td>' +
                    '<td></td>' +
                    '<td></td>' +
                    '</tr>'
                  )
                )
                .show();
            }
          });

Problem : it's not working the child rows are never displayed. Same thing with createdRow.

DataTables 1.10.21

This question has accepted answers - jump to:

Answers

Sign In or Register to comment.