YUI Datatable Not Taking JSON
- by Pete Herbert Penito
I am trying to fill a Datatable with a JSON using YUI,
I have this JSON:
[{"test":"value1",
"test2":"value2",
"test3":"value3",
"topic_id":"123139007E57",
"gmt_timestamp":1553994442,
"timestamp_diff":-1292784933382,
"status":"images\/statusUp.png",
"device_id":"568FDE9CC7275FA"}, ..
It continues like this with about 20 different devices, and I close it with a ]
I just want to print select keys in the datatable so my Column Definitions look like this:
var myColumnDefs = [
{key:"test", sortable:true, resizeable:true},
{key:"test2", sortable:true, resizeable:true},
{key:"topic_id", sortable:true, resizeable:true},
{key:"status", sortable:true, resizeable:true},
{key:"device_id", sortable:true, resizeable:true},
];
var myDataSource = new YAHOO.util.DataSource(bookorders);
myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSARRAY;
myDataSource.responseSchema = {
fields: ["test","test2","topic_id","status","device_id"]
};
var myDataTable = new YAHOO.widget.DataTable("basic",
myColumnDefs, myDataSource);
It's print Data Error for some reason, what am I doing wrong?
Thanks!
I have tested the validity of the JSON at JSONLint and it says it is valid.