我已经使用https://datatables.net/reference/api/rows.add%28%29链接工作,但数据显示表格为[object,object]
。如何将对象显示为字符串。我已经使用JSON.stringify(obj)
它也没有工作。如何在数据表中添加多行jquery
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();
});
请出示你的代码 – neelsg
向我们展示你的代码 –
把我们的代码ñHTML中的问题通过点击编辑,而不是在评论 – Se0ng11