jquery datatable plugin aadata format not displaying the table
jquery datatable plugin aadata format not displaying the table
Iam newbie to jquery. Iam working with jquery datatable plugin . I tried to display the array of aadata with datatable but iam not getting datatable displayed, only empty page i could see.
Can anyone help me where i went wrong?
Below is the code i used.
[code] $(document).ready(function () {
var Listobj = new Array();
var downloadClick = ""
var callPlayVedio = ""
$.getJSON("sources/jsondata.json", function (data) {
var dataobj = $.parseJSON(JSON.stringify(data));
$.each(dataobj, function (key, val) {
if (key == "contents") {
for (var i = 0, l = val.length; i < l; i++) {
var obj = val[i];
var auctualSize = ((obj.size) / 1024).toFixed(2) + " kb";
Listobj[i] = new Array(obj.key, obj.lastModified, auctualSize, downloadClick, callPlayVedio, "");
}
}
});
TableDisplay(Listobj);
});
});
function TableDisplay(Tablevalues) {
alert("sec"+Tablevalues);
$('#table_test').html('');
$('#example').dataTable({
"aaData": Tablevalues,
"aoColumns": [
{ "sTitle": "Files" },
{ "sTitle": "Date and Time" },
{ "sTitle": "size"},
{ "sTitle": "Download"},
{ "sTitle": "Play"},
{"sTitle": "share"}]
});
};
and my json values are
var myjson='[{"isTruncated": "false","nextMarker": "null","marker": "null","prefix": "Mymedia/mysys/","contents": [{"deviceInfo": "null","lastModified": "Thu Dec 26 16:36:42 IST 2013","etag": "d41d8cd98f00b204e9800998ecf8427e","key":"Mymedia/mysys/audio_$folder$","size": "0"},{"deviceInfo": null,"lastModified": "Thu Dec 26 16:36:11 IST 2013","etag": "d41d8cd98f00b204e9800998ecf8427e","key": "Mymedia/mysys/doc_$folder$","size": "0"},{ "deviceInfo": null,"lastModified": "Thu Dec 26 16:36:20 IST 2013", "etag": "d41d8cd98f00b204e9800998ecf8427e","key": "Mymedia/mysys/imge_$folder$","size": "0"},{"deviceInfo": null,"lastModified": "Thu Dec 26 16:36:56 IST 2013","etag": "d41d8cd98f00b204e9800998ecf8427e","key":"Mymedia/mysys/others_$folder$","size": "0"},{"deviceInfo": null,"lastModified": "Thu Dec 26 16:36:32 IST 2013","etag": "d41d8cd98f00b204e9800998ecf8427e","key": "Mymedia/mysys/video_$folder$","size": "0"}],"name": "name", "statusCode": "200","statusMessage": "Success","error": null}]';
[/code]
Can anyone help me where i went wrong?
Below is the code i used.
[code] $(document).ready(function () {
var Listobj = new Array();
var downloadClick = ""
var callPlayVedio = ""
$.getJSON("sources/jsondata.json", function (data) {
var dataobj = $.parseJSON(JSON.stringify(data));
$.each(dataobj, function (key, val) {
if (key == "contents") {
for (var i = 0, l = val.length; i < l; i++) {
var obj = val[i];
var auctualSize = ((obj.size) / 1024).toFixed(2) + " kb";
Listobj[i] = new Array(obj.key, obj.lastModified, auctualSize, downloadClick, callPlayVedio, "");
}
}
});
TableDisplay(Listobj);
});
});
function TableDisplay(Tablevalues) {
alert("sec"+Tablevalues);
$('#table_test').html('');
$('#example').dataTable({
"aaData": Tablevalues,
"aoColumns": [
{ "sTitle": "Files" },
{ "sTitle": "Date and Time" },
{ "sTitle": "size"},
{ "sTitle": "Download"},
{ "sTitle": "Play"},
{"sTitle": "share"}]
});
};
and my json values are
var myjson='[{"isTruncated": "false","nextMarker": "null","marker": "null","prefix": "Mymedia/mysys/","contents": [{"deviceInfo": "null","lastModified": "Thu Dec 26 16:36:42 IST 2013","etag": "d41d8cd98f00b204e9800998ecf8427e","key":"Mymedia/mysys/audio_$folder$","size": "0"},{"deviceInfo": null,"lastModified": "Thu Dec 26 16:36:11 IST 2013","etag": "d41d8cd98f00b204e9800998ecf8427e","key": "Mymedia/mysys/doc_$folder$","size": "0"},{ "deviceInfo": null,"lastModified": "Thu Dec 26 16:36:20 IST 2013", "etag": "d41d8cd98f00b204e9800998ecf8427e","key": "Mymedia/mysys/imge_$folder$","size": "0"},{"deviceInfo": null,"lastModified": "Thu Dec 26 16:36:56 IST 2013","etag": "d41d8cd98f00b204e9800998ecf8427e","key":"Mymedia/mysys/others_$folder$","size": "0"},{"deviceInfo": null,"lastModified": "Thu Dec 26 16:36:32 IST 2013","etag": "d41d8cd98f00b204e9800998ecf8427e","key": "Mymedia/mysys/video_$folder$","size": "0"}],"name": "name", "statusCode": "200","statusMessage": "Success","error": null}]';
[/code]
This discussion has been closed.