Warning - added data does not match known number of columns

Warning - added data does not match known number of columns

brettbrett Posts: 3Questions: 0Answers: 0
edited January 2010 in General
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?

Replies

  • brettbrett Posts: 3Questions: 0Answers: 0
    Thanks for your attention.
    I have fixed the problem.
    The reason was that my database added another column to mark the row number automatically.
    DataTables is great!!
  • GusGus Posts: 18Questions: 0Answers: 0
    brett,
    I am having the exact same issue

    What did you do to fix this?

    Thanks
  • brettbrett Posts: 3Questions: 0Answers: 0
    Gus,

    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!
  • GusGus Posts: 18Questions: 0Answers: 0
    bret,
    Thanks I am checking that now!

    Gus
  • pwc1011pwc1011 Posts: 62Questions: 0Answers: 0
    Different things cause this issue, I've seen the message

    - 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
  • GusGus Posts: 18Questions: 0Answers: 0
    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
  • pwc1011pwc1011 Posts: 62Questions: 0Answers: 0
    My pleasure. We struggled some to get things working, but now that we have it down, datatables is really working well for us. I hope you like it as much as we do!

    Patrick
  • GusGus Posts: 18Questions: 0Answers: 0
    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
  • pwc1011pwc1011 Posts: 62Questions: 0Answers: 0
    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
  • GusGus Posts: 18Questions: 0Answers: 0
    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
  • GusGus Posts: 18Questions: 0Answers: 0
    Patrick,
    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
This discussion has been closed.