how to create tfoot for dynamically created table

how to create tfoot for dynamically created table

SriRishithaSriRishitha Posts: 42Questions: 4Answers: 0

i wrote the code like this
table = $('#viewtbl').DataTable({
columns: cols,

                  ServerSide: true,
                  dom: 'Bfrtip',
                  buttons: [
                     {
                         extend: 'print',
                         autoPrint: true,
                        // className: 'btn btn-primary glyphicon glyphicon-print',
                        // text: '<i class="fa fa-print">Print</i>',
                         //title: $('h1').text(),
                         exportOptions: {
                             //columns: ':not(.no-print)'
                             columns: ':visible', stripNewlines: true
                         },
                         title: row.RepName,
                         orientation: 'landscape',
                         pageSize: 'C2',
                         footer: false
                     },
                      {
                          extend: 'excelHtml5', footer: true, exportOptions: {
                              columns: ':visible', stripNewlines: false
                          },
                          //className: 'btn btn-primary glyphicon glyphicon-list-alt',
                          //text: '',
                          title: row.RepName,
                          orientation: 'landscape',
                          pageSize: 'LEGAL',
                      },
                      {

                          extend: 'pdfHtml5',
                          //className: 'btn btn-primary glyphicon glyphicon-file',
                          columns: ':visible',
                          orientation: 'landscape',
                          title: row.RepName,
                          pageSize: 'C2',
                          text: '<i class="fa fa-file-pdf-o"></i>Pdf',

                          footer: false
                      },

                      {
                          extend: 'colvis',
                          columnText: function (dt, idx, title) {
                              return title;
                          },
                         // className: 'btn btn-primary glyphicon glyphicon-th icon-th',
                          postfixButtons: ['colvisRestore']
                      },
                       {
                           extend: 'pageLength', footer: false, exportOptions: {
                               stripNewlines: false
                           }
                       },
                  ],
                  iDisplayLength: 25,
                  lengthMenu: [[10, 25, 50, -1],
                      ['10', '25', '50', ' all']
                  ],
                  pagingType: "full_numbers",
                  deferRender: true,
                  destroy: true,
                  "fnDrawCallback": function (oSettings) {
                      debugger
                      if ($('#viewtbl tr').length <= 11) {
                          $('.buttons-page-length').hide();
                      }
                      else {
                          $('.buttons-page-length').show();
                      }
                  }

              });
             table.rows.add(resp).draw();

$('#viewtbl thead th').each(function (i) {
var title = $('#viewtbl thead th').eq($(this).index()).text();
$(this).html('<input type="text" placeholder="Search ' + title + '" data-index="' + i + '" />');
});
$(table.table().container()).on('keyup', 'thead input', function () {
table
.column($(this).data('index'))
.search(this.value)
.draw();
});

but i want add search in tfoot. any one done this one please help me.

Replies

This discussion has been closed.