【发布时间】:2019-10-26 23:16:51
【问题描述】:
我正在尝试将 Json 数据加载到数据表中但不加载
请在下面找到数据表代码
function loadItemDetails(jsonData ) {
$('#itemsDetails').DataTable( {
mData: jsonData ,
columns: [
{ data: "netAmount" }
]
} );
在 HTML 表格代码中:
<table class="table" id="itemsDetails">
<thead class="table-head">
<tr>
<th scope="col">Sr. No.</th>
<th scope="col">Qty</th>
<th scope="col">Net Amount</th>
<th scope="col">Promo</th>
<th scope="col">CB</th>
</tr>
</thead>
</table>
Json 数据:
var jsonData = [{"netAmount":"20"},{"netAmount":"20"},{"netAmount":"20"}];
【问题讨论】:
-
你试过调试'jsonData'变量吗?如果是,请将其作为硬编码值提供
-
硬编码的意思?
-
提供您期望的价值
-
提供硬编码数据但仍未加载。我需要初始化吗?