Upgrade from 1.5.6 to 1.8.2 getting errors

Upgrade from 1.5.6 to 1.8.2 getting errors

czj08cczj08c Posts: 8Questions: 0Answers: 0
edited December 2011 in DataTables 1.8
Hi,
I am trying to upgrade from dt 1.5.6 to 1.8.2. I am now getting errors in this piece of code:
function _fnSetCellData( oSettings, iRow, iCol, val )
{
var oCol = oSettings.aoColumns[iCol];
var oData = oSettings.aoData[iRow]._aData;

oCol.fnSetData( oData, val );
}

The error is 'MS jscript runtime error "undefined" is null or not an object." It seems the var oCol is not being set correctly.
I did some searches and found that some issues using colspan, although this worked fine in 1.5.6.

Here is my datatable setup script:
$(document).ready(function() {
var aColumns = [null];
if ($('#example thead th').length != 1) {
aColumns = [null, null, null, null,{ "bSortable": false }];
} else {
$('#example tbody tr').remove()
}
$('#example').dataTable({
"iDisplayLength": 10,
"aaSorting": [[0, "asc"]],
"aoColumns": aColumns,
"bStateSave": true
});

Here is my HTML:





Student
District
Submitted 
Status
Actions



<%foreach (var item in Model)
{ %>

<%= Html.Encode(item.FirstName + " " + item.LastName)%>
<%= Html.Encode(item.Name) %>
<%= Html.Encode(String.Format("{0:d}", item.SubmittedDate))%>
<%= Html.Encode(item.Status) %>






















<%if (item.Status == VLINC.Models.CommonData.StudentState.Unfinished.ToString()) { %>



<% }
else if (item.Status == VLINC.Models.CommonData.StudentState.Submitted.ToString()) { %>



<% }
else { %>
 
<% } %>


<% } %>




Basically my table has 5 columns with the last column being a group of up to 8 icons that are links to other pages. Like I said this worked in version 1.5.6.

Thanks,
Glenn

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    Hi Glenn,

    I must admit I'm surprised that this worked in any version of DataTables - if it worked in 1.5.6 then it was a bug in itself rather than a feature! Basically the following equation must be true:

    > rows * columns = cells

    In the case above you have a lot more cells than DataTables is expecting since you have a colspan in the header, and no unique header cell for those columns. Colspan in the header is fine, but there _must_ be a unique TH element in the header for each columns (since this is how DataTables does filtering, sorting, column visibility etc). I understand you don't need those features for those columns, but I'm afraid that it is currently a hard requirement.

    One option would be to have a second row in the header with those unique cells that will meet the requirements for DataTables. You could then remove that TR element from the DOM and that should allow everything to work.

    Allan
This discussion has been closed.