[英]Datatable columndefs not being hit
I have been trying to render my json in datatable.我一直在尝试在数据表中呈现我的 json。 The json format i have been working with is as follows:
我一直在使用的 json 格式如下:
{
message: "",
data: {
count: "",
result: [
{
parameter1: "",
parameter2: "",
parameter3: "",
},
{
parameter1: "",
parameter2: "",
parameter3: "",
},
]
}
}
Datatable Code is as follow数据表代码如下
$('#example').DataTable({
"processing": true,
"serverSide": true,
"ajax": {
url: "https://c22c6e75-a9b9-4762-8f5d-b25137536fa6.mock.pstmn.io/iprSearchData",
},
"columnDefs": [
{
"targets": [0],
"data": function (row, type, val, meta) {
// not hitting
console.log(row);
console.log(type);
console.log(val);
console.log(meta);
},
"render": function (data, type, row) {
console.log(data);
console.log(row);
return data;
},
},
// {targets: [0], visible: true},
// {targets: '_all', visible: false}
]
});
I read the documentation and I assume the data(JSON) format is creating problems for me in rendering or is it some other issue?我阅读了文档,我认为数据(JSON)格式在渲染时给我带来了问题,还是其他一些问题? I want to render my parameters in reult array of the JSON to be displayed in a single column.
我想在要显示在单个列中的 JSON 的结果数组中呈现我的参数。
Thanks in advance.提前致谢。
The JSON format was the issue. JSON 格式是问题所在。 Use datasrc in ajax for appropriate data from the returned ajax.
在 ajax 中使用 datasrc 从返回的 ajax 中获取适当的数据。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.