IE7 Warning - added data does not match known column length

IE7 Warning - added data does not match known column length

Luda AmebaLuda Ameba Posts: 11Questions: 0Answers: 0
edited July 2009 in Bug reports
I have problem with adding data like in previous post http://datatables.net/forums/comments.php?DiscussionID=418&page=1#Comment_2136. Thing that I wonted to do is to have data table with 2 columns than dynamically create more columns for buttons.
[code]
var tbl = $("#tbl").dataTable( {
"fnHeaderCallback": function( nHead, aasData, iStart, iEnd, aiDisplay ) {
$(nHead).empty();
$(nHead).append('New column1');
$(nHead).append('Old column')
$(nHead).append('New column2');
$(nHead).append(' New column3');
},
"fnRowCallback": function( nRow, aData, iDisplayIndex ) {
$(nRow).empty();
$(nRow).append('…')
$(nRow).append('' + aData[1] + '');
$(nRow).append('

Replies

  • allanallan Posts: 61,446Questions: 1Answers: 10,054 Site admin
    Hi Luda,

    I believe that there are two problems here:

    1. Your JSON is invalid (you've got a trailing comma in the aoColumn array which IE7 (correctly) rejects
    2. Your columns in the HTML do not match the number of columns in aoColumns.

    As noted in the other thread, the column length must match, and this solved the problem in the other thread. Try this:

    [code]
    "aoColumns": [
    { "sTitle": "ID", "bVisible": false },
    { "sTitle": "Name" },
    null,
    null,
    null
    ]
    [/code]

    Allan
  • Luda AmebaLuda Ameba Posts: 11Questions: 0Answers: 0
    Hi Allan tnx for quick replay, comma was the problem.
    Sorry for bothering for such simple thing, 8h working cause that problem at the end (stupid cope/paste of code) and I was too tired to notice that :-)
    It is working without null values

    [code]"aoColumns": [
    { "sTitle": "ID", "bVisible": false },
    { "sTitle": "Name" }
    ]
    [/code]

    Luda Ameba
  • allanallan Posts: 61,446Questions: 1Answers: 10,054 Site admin
    Hi Luda,

    Excellent stuff. Interesting that it works with out the null values, but perhaps no to surprising with dynamic data... Either way, we'll go with it :-)

    Allan
This discussion has been closed.