Warning - added data does not match known number of columns
Warning - added data does not match known number of columns
Hi expert,
I am a new to DataTables. When I tried my first application, the web page gave me 10 alert message: Warning - added data does not match known number of columns.
And the result set was empty. My DataTables version is 1.5.2, The browsers are FF 3.5 and IE 8
[code]
$(document).ready(function() {
$('#questionTable').dataTable( {
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "DataTable.action"
} );
} );
column1
column2
column3
column4
[/code]
I am sure the aaData contains several records which have 4 columns. Could you give me some hints about how to fix the problem?
I am a new to DataTables. When I tried my first application, the web page gave me 10 alert message: Warning - added data does not match known number of columns.
And the result set was empty. My DataTables version is 1.5.2, The browsers are FF 3.5 and IE 8
[code]
$(document).ready(function() {
$('#questionTable').dataTable( {
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "DataTable.action"
} );
} );
column1
column2
column3
column4
[/code]
I am sure the aaData contains several records which have 4 columns. Could you give me some hints about how to fix the problem?
This discussion has been closed.
Replies
I have fixed the problem.
The reason was that my database added another column to mark the row number automatically.
DataTables is great!!
I am having the exact same issue
What did you do to fix this?
Thanks
I checked the aaData in debug mode and found there was a column containing the row num which was unwanted.
Then I made some modifications in my SQL statement.
Hope it helps.
Thanks!
Thanks I am checking that now!
Gus
- when the echo returned does not match the echo sent
- when the rows in the results json are not the same - aaData
- when there are field names in the json results - aaData
use the console in firefox to debug your results. make sure the json array does not have field names and the number of data values matches the number of columns.
if you have three columns in your table, two rows of data should look:
[ [ "r1col1val", "r1col2val", "r1col3val" ], ["r2col1val","r2col2val","r2col3val"]]
and NOT like
[ [ "col1name": "r1col1val", "col2name":"r1col2val", "col3name":"r1col3val" ], ["col1name": "r2col1val", "col2name":"r2col2val", "col3name":"r2col3val" ] ]
Patrick
Thanks so much for your input.
I has been very helpfull and I think I have this issue resolved now.
Seems to me it's always the little things I do that mess me up!
Thanks!
Gus
Patrick
This is my first pass too. It's going slow and steady now.
I agree once the first time through is done, it will be a breeze from there.
I really like it so far, and the client I am doing this for thinks the themed UI is beautiful.
Gus
The one thing that really caused us headaches was the "node" versus "element." jQuery returns elements by default, whereas, the datatables uses nodes. It's just a matter of using the jQuery get() instead of selector element.
For instance, when datatables is referring to nTr, it's not $('tr') it's $('tr').get(0) or $('tr)[0].
I'm embarrassed to say this caused us MANY hours of headache!
Patrick
How do you guys handle filters on top of dataTables, where the filter data is not in the dataTables view,
but are used as select statements on the server side? Make sense or is there a better way to do this?
Thanks,
Gus
I think I just figured out my last question,
I see now you use fnServerData and push aoData
dataTables does a lot and I see it will take some time to see what all it does!!
Thanks for all the dialog!
Gus