Cómo agregar múltiples filas en tablas de datos jquery
He usadohttps://datatables.net/reference/api/rows.add%28%29 enlace funcionando pero los datos que muestran la tabla como[object,object]
. Cómo mostrar el objeto a la cadena. He usadoJSON.stringify(obj)
Tampoco funciona.
HTML
<table id="exampleTable">
<thead>
<tr>
<th>Year</th>
<th>Month</th>
<th>Savings</th>
</tr>
</thead>
<tbody>
<tr>
<td>2012</td>
<td>January</td>
<td>$100</td>
</tr>
<tr>
<td>2012</td>
<td>February</td>
<td>$80</td>
</tr>
</table>
JS
$('#addRows').click();
var table3 = $('#exampleTable').DataTable();
$('#addRows').on( 'click', function () {
table3.row.add(
[ { "Year": "Tiger Nixon", "Month": "System Architect", "Savings": "$3,120" },
{"Year": "Tiger Nixon", "Month": "System Architect", "Savings": "$3,120" }]
).draw();
});