Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jquery DataTables not working for append html using javascript

I am using a jQuery DataTables style for the responsive layout, but when I use javascript to append <td>Mycode</td> in the table, then the dataTables style not working, any idea?

like image 603
Winston Avatar asked May 25 '26 05:05

Winston


1 Answers

DataTable does not work in append in javascript, because after calling .DataTable method our append method calls. If you debug your javascript code, then you will find that .DataTable call before .append. Check our table body, it does not render at time when .DataTable calls. So write .DataTable method after .append method.

$('#grdWrkServiceEntry').append(tableBody);
$('#grdWrkServiceEntry').DataTable();

I also faced the same problem, but now it is resolved.

like image 127
Amit Nikam Avatar answered May 26 '26 18:05

Amit Nikam



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!