创建表格;
var table = $("#tbl-inventory-report").DataTable({
ajax: {
url: "/api/inventory",
dataSrc: "",
},
"oLanguage": {
"sProcessing": ""
},
processing: true,
columns: [
{
data: "Id",
className: "visible-lg",
},
{
data: "Employee.LogonName"
}
]
});
Ajax请求的Json结果示例;
{
Id:3434,
Employee:{
Id:10,
LogonName:"Example10"
}
}
我收到错误的JS代码;
table.row.add({
"Id": 11,
"Employee.LogonName": "Example11",
}
加载页面时数据加载成功。但是,当我想稍后添加行时,我收到以下错误。有什么想法吗?
请求第2856行第1列的未知参数“Employee.LogonName”。
答案 0 :(得分:3)
由于您的库存API中定义了记录结构,您需要更改此行:
Workbook
为:
table.row.add({
"Id": 11,
"Employee.LogonName": "Example11",
}