Uncaught TypeError: Cannot read property 'length' of undefined jquery.datatables.js:1918
Uncaught TypeError: Cannot read property 'length' of undefined jquery.datatables.js:1918
strokes
Posts: 8Questions: 0Answers: 0
Hi guys.
My JSON Response is:
[code][{"id":"vammcxks","businessId":"fovkfslw","group":{"id":"Czrzep","name":"Willy","status":"OK","dateCreated":1306800420000},"name":"Jules","status":"OK","address":"89 S. Riverside Plaza", ...[/code]
Without root "aaData" which I guess is causing the problem because in jquery.datatables.js:1918 it's getting called 'aData.length';
In Chrome console: Uncaught TypeError: Cannot read property 'length' of undefined jquery.datatables.js:1918
How can I eliminate this problem? I cannot change much on server side, I'm using a framework there that returns the JSON response.
Thanks in advance.
My JSON Response is:
[code][{"id":"vammcxks","businessId":"fovkfslw","group":{"id":"Czrzep","name":"Willy","status":"OK","dateCreated":1306800420000},"name":"Jules","status":"OK","address":"89 S. Riverside Plaza", ...[/code]
Without root "aaData" which I guess is causing the problem because in jquery.datatables.js:1918 it's getting called 'aData.length';
In Chrome console: Uncaught TypeError: Cannot read property 'length' of undefined jquery.datatables.js:1918
How can I eliminate this problem? I cannot change much on server side, I'm using a framework there that returns the JSON response.
Thanks in advance.
This discussion has been closed.
Replies
Allan
I have done that but still the exact same problem.
Here's my table:
[code]var oTable = $('#merchantsTable').dataTable({
"bProcessing": true,
"sAjaxDataProp":"",
"bServerSide": true,
"sAjaxSource": "${pageContext.request.contextPath}/"
}); [/code]
If I remove the "bServerSide", the request type becomes "text/html", which of course doesn't work.
What else causes this problem?
Allan
I'm close.
I fixed server side and JSON now looks ok to me:
(copied from Chrome)
[code]aaData: [{id:vammcxks, businessId:fovkfslw,…}, {id:abbtorgp, businessId:qpehxtxt,…},…]
iDisplayLength: 10
iDisplayStart: 0
sEcho: "10"
[/code]
But I have this message:
"DataTables warning(table= id="merchantsTable"): Requested unknown parameter '0' from the data source for row 0"
and the footer is
"Showing 1 to NaN of NaN entries (filtered from NaN total entries)"
iDisplayLength: 10
iDisplayStart: 0
[/quote]
The server doesn't send those parameters back, it sends iTotalDisplayRecords and iTotalRecords among others. Have a look at the page again :-)
Also have you used mData to tell DataTables what property to read from the data source objects?
Allan
[code]aaData: [{id:vammcxks, businessId:fovkfslw,…}, {id:abbtorgp, businessId:qpehxtxt,…},…]
iTotalDisplayRecords: 10
iTotalRecords: 500
sEcho: "10"[/code]
I tried mData, but still the same warning and the data misses.
[code]var oTable = $('#merchantsTable').dataTable({
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "${pageContext.request.contextPath}/",
"aoColumns" : [
{ "mData": "businessId" },
{ "mData": "name" },
{ "mData": "merchantGroup.2" },
{ "mData": "webAddress" },
{ "mData": "createdOn" },
{ "mData": "status" }
]
}); [/code]
merchantGroup - has nested values, i need the third one(name), hence { "mData": "merchantGroup.2" }.
Is that correct? As the documentation says:
> Total records, after filtering (i.e. the total number of records after filtering has been applied - not just the number of records being returned in this result set)
> merchantGroup - has nested values, i need the third one(name), hence { "mData": "merchantGroup.2" }.
As in it is an array? That should work. Can you please either give me a link or use the DataTables debugger so I can access the information needed to be able to answer the question :-)
Allan
iTotalDisplayRecords - is ok I guess because I'm returning the size of the list after getting from database.
Here's the link of debugger http://debug.datatables.net/inibal
Yes I need server-processing, I'm going to display very large lists.
Thanks
However, about the united property, you've got:
> { "mData": "merchantGroup.2" }.
which would access array index 2, but your data source object for merchantGroup is an object, not an array:
[code]
"merchantGroup": {
"id": "Czrzep",
"name": "Willy",
"status": "OK",
"dateCreated": 1306800420000
},
[/code]
So you need to use `merchantGroup.id` or something like that since `2` has no meaning for that object.
Allan
"DataTables warning(table= id="merchantsTable"): Requested unknown parameter '0' from the data source for row 0"
http://debug.datatables.net/anavad
Allan
I have another question but maybe I'll go with another thread.