Skip to content

Instantly share code, notes, and snippets.

@kagemusha
Created January 23, 2012 08:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kagemusha/1661626 to your computer and use it in GitHub Desktop.
Save kagemusha/1661626 to your computer and use it in GitHub Desktop.
JQuery Datatables Errors
Seen on: Datatables 1.8.x
1. c[b[0]] is undefined
Check aoColumns prop. E.g. if obj.name below not defined will cause error. If are using
"aoColumns": [
{ "sWidth": '200px', "mDataProp": "obj.name" },
If are setting col val in "fnRowCallback" prop, set mDataProp to null to avoid this problem.
2. Uncaught TypeError: Cannot read property 'length' of undefined
Happens for server-side processing when no aaData prop in the server response.
Correct should be something like:
def datatable_data
@objs = #some finder method
data = DataTableWrapper.new #this is just some obj encapsulating resp
data.sEcho = params[:sEcho].to_i
data.iTotalRecords = #tot recs in this set
data.iTotalDisplayRecords = #recs to display
data.aaData = @objs
render :json=>data.to_json
end
Ref: http://datatables.net/forums/discussion/6101/cannot-read-property-length-of-undefined-with-ajax-source/p1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment