0

$("#example1").DataTable({ "responsive": true, "lengthChange": true, "autoWidth": false, "buttons": ["copy", "csv", "excel", "pdf", "print", "colvis", ], data: this.voucherDTO, columns: [ { data: 'voucherno'}, { data: 'accountof' }, { data: 'accountHead.accountHead.name' }, { data: 'amount' }, { data: 'narration' }, { data: 'vdate'}, { data: null, defaultContent: '<button type="button" class="btn btn-primary btn-block" ><i class="fa fa-edit"></i></button>', createdCell: this.doSomething() }], }).buttons().container().appendTo('#example1_wrapper .col-md-6:eq(0)');

It is showing data table perfectly but when I click on respective row edit button the dosomething() function does not work.

i tried to add :

createdCell: function(cell: any, cellData: any, rowData: any, rowIndex: any, colIndex: any) {
            // Add click event to action button
            $(cell).find('button').click(function() {
              // Call component function on button click
              this.doSomething(rowData);
            });
          }

above function call but it show error: 'this' implicitly has type 'any' because it does not have a type annotation.ts(2683)

I need to call a component function with rowindex to call api with the specific row data.

0 Answers0