Created
January 23, 2012 08:11
-
-
Save kagemusha/1661626 to your computer and use it in GitHub Desktop.
JQuery Datatables Errors
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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