IE7 Warning - added data does not match known column length
IE7 Warning - added data does not match known column length
![Luda Ameba](https://secure.gravatar.com/avatar/077bfce47e6142977ddb6ed8a4ad0448/?default=https%3A%2F%2Fvanillicon.com%2F077bfce47e6142977ddb6ed8a4ad0448_200.png&rating=g&size=120)
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('
[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('
This discussion has been closed.
Replies
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
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
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