JSON data with property name "length" causes a bug
JSON data with property name "length" causes a bug
Hi,
this is my data
var ds_playlist = [
{
"stime": "2011-08-23T12:40:02",
"status": 0,
"channel": "RADIO ZU",
"artist": "DAN BALAN",
"title": "FREEDOM (RADIO-VIDEO EDIT)",
"track": "DAN BALAN - FREEDOM (RADIO-VIDEO EDIT)",
"position": 45,
"duration": 196,
"length": 215
},
{
"stime": "2011-08-23T12:35:32",
"status": 0,
"channel": "KISS FM",
"artist": "DAN BALAN",
"title": "FREEDOM (RADIO MIX)",
"track": "DAN BALAN - FREEDOM (RADIO MIX)",
"position": 5,
"duration": 182,
"length": 212
},..
running the table generates an error of Uncaught TypeError: Object # has no method 'slice'
it took me hours to debug and found that when i remove the property "length" everything is ok
can u please instruct what should i do since the property "length" cannot be changed on my side
here is my datatable init
$(document).ready(function () {
$('.btnEdit').button({icons: {primary: "ui-icon-pencil"}, text: true});
$('#nttgrid').dataTable({
"bJQueryUI": true,
"bAutoWidth": false,
"sPaginationType": "full_numbers",
"sDom": 'T<"clear"><"H"lfr>t<"F"ip>',
"aaData": kuku_data,
"aoColumns": [
{ "mDataProp": "stime", "sTitle": "<%= Resources.Resource.StartTime %>" },
{ "mDataProp": "status", "sTitle": "<%= Resources.Resource.TypeOfBroadcast %>" },
{ "mDataProp": "channel", "sTitle": "<%= Resources.Resource.Channel %>" },
{ "mDataProp": "artist", "sTitle": "<%= Resources.Resource.Artist %>" },
{ "mDataProp": "title", "sTitle": "<%= Resources.Resource.SongTitle %>" },
{ "mDataProp": "track", "sTitle": "<%= Resources.Resource.Track %>" },
{ "mDataProp": "position", "sTitle": "<%= Resources.Resource.Position %>", "sClass": "center" },
{ "mDataProp": "duration", "sTitle": "<%= Resources.Resource.Duration %>", "sClass": "center" }
]
});
});
TIA
this is my data
var ds_playlist = [
{
"stime": "2011-08-23T12:40:02",
"status": 0,
"channel": "RADIO ZU",
"artist": "DAN BALAN",
"title": "FREEDOM (RADIO-VIDEO EDIT)",
"track": "DAN BALAN - FREEDOM (RADIO-VIDEO EDIT)",
"position": 45,
"duration": 196,
"length": 215
},
{
"stime": "2011-08-23T12:35:32",
"status": 0,
"channel": "KISS FM",
"artist": "DAN BALAN",
"title": "FREEDOM (RADIO MIX)",
"track": "DAN BALAN - FREEDOM (RADIO MIX)",
"position": 5,
"duration": 182,
"length": 212
},..
running the table generates an error of Uncaught TypeError: Object # has no method 'slice'
it took me hours to debug and found that when i remove the property "length" everything is ok
can u please instruct what should i do since the property "length" cannot be changed on my side
here is my datatable init
$(document).ready(function () {
$('.btnEdit').button({icons: {primary: "ui-icon-pencil"}, text: true});
$('#nttgrid').dataTable({
"bJQueryUI": true,
"bAutoWidth": false,
"sPaginationType": "full_numbers",
"sDom": 'T<"clear"><"H"lfr>t<"F"ip>',
"aaData": kuku_data,
"aoColumns": [
{ "mDataProp": "stime", "sTitle": "<%= Resources.Resource.StartTime %>" },
{ "mDataProp": "status", "sTitle": "<%= Resources.Resource.TypeOfBroadcast %>" },
{ "mDataProp": "channel", "sTitle": "<%= Resources.Resource.Channel %>" },
{ "mDataProp": "artist", "sTitle": "<%= Resources.Resource.Artist %>" },
{ "mDataProp": "title", "sTitle": "<%= Resources.Resource.SongTitle %>" },
{ "mDataProp": "track", "sTitle": "<%= Resources.Resource.Track %>" },
{ "mDataProp": "position", "sTitle": "<%= Resources.Resource.Position %>", "sClass": "center" },
{ "mDataProp": "duration", "sTitle": "<%= Resources.Resource.Duration %>", "sClass": "center" }
]
});
});
TIA
This discussion has been closed.
Replies
Please return the data as len
And why can it not be changed?
[code]
var aDataIn = (typeof aDataSupplied.length == 'number') ?
[/code]
I've just committed a fix for this which you can pick up from the DataTables download page as the 1.8.2.dev nightly: http://datatables.net/download . The fix is to use the jQuery method $.isArray which is designed for exactly this sort of thing!
Regards,
Allan