How to Add new row to datatable using jquery datatable
By Tan Lee Published on Feb 16, 2024 797
This post shows you how to add new row to datatable using jquery datatable.net
For example
<table border="1"> <thead> <tr><td>Customer ID</td><td>Customer Name</td> <tr> </thead> <tr> <td>01</td> <td>John</td> </tr> <tr> <td>02</td> <td>Lucy</td> </tr> </table>
You can use fnAddData to add row with an array of the values that you want to add.
var table = $('#tbl').DataTable(); var total = table.data().count(); var column1 = 'col 1'; var column2 = 'col 2'; $('#tbl').dataTable().fnAddData([column1, column2 ]);
If you want to embed html control you can write.
var column1 = '<input type="text" id="AddressList_' + total + '__Name" name="AddressList[' + total + '].Name" value="' + data.Name + '">';
And from version 1.10 you can use row.add() method
var newRow = "<tr><td>col 1</td><td>col 2</td></tr>"; var table = $('#tbl').DataTable(); table.row.add($(newRow )).draw();
- How to add class to tr using jQuery datatable
- How to disable sorting with jquery datatable
- How to hide “Showing 1 of N Entries” with jQuery datatables
- How to Change parameter used in datatables ajax url.Action on Ajax.reload
- How to fix 'Requested unknown parameter '6' for row 0, column 6'
- Ho to add class to column dynamically using jQuery datatable
- How to remove no data available in table from datatable in jQuery
- How to Rename “show XX entries” dropdown in DataTables
Categories
Popular Posts
Portal HTML Bootstrap
Nov 13, 2024
Freedash bootstrap lite
Nov 13, 2024
Implementing Caching in ASP.NET Core
Dec 14, 2024
11 Things You Didn't Know About Cloudflare
Dec 19, 2024