Problem with JSON nested values.
Problem with JSON nested values.
I have an AJAX datatable. It succesfully took AJAX JSON data but failed when I tried nested data.
The JSON data looks just fine. And I don't see my mistake with the nesting.
My page:
http://jtc.ae/?page=s_page&s_text=test&p_num=1&item_num=20
The warning:
DataTables warning: table id=dynamic_table - Requested unknown parameter 'post_meta.retail_from_usd' for row 0, column 2.
How I nest the Data:
dyn_t = $('#dynamic_table').DataTable({
"ajax": {
"url":ajax_dt_url,
"dataSrc":""
},
"columns": [
{ "data" : "post_title" },
{ "data" : "post_meta.price_input" },
{ "data" : "post_meta.retail_from_usd" },
{ "data" : "post_meta.moq_num" },
{ "data" : "post_meta.lead_t" },
{ "data" : "post_meta.specification_txt" },
{ "data" : "id" },
],
});
I don't see my mistake. Could this be a bug?
Best regards,
-Luca Ban
This question has an accepted answers - jump to answer
Answers
No its not a bug. This is the data that is being returns from the server:
As you can see, there is no
retail_from_usd
property in thepost_meta
object. DataTables is telling you exactly what the error is :-)Allan
Hey allan,
Can i set the field to blank if the value doesn't exist inside postmeta?
Sure - use
columns.defaultContent
.Allan