DataTables is broken when using two rows of headers and a column in the top row only spans 1 column
DataTables is broken when using two rows of headers and a column in the top row only spans 1 column
ejeliot
Posts: 5Questions: 0Answers: 0
DataTables doesn't appear to be working when I have two rows of headers and a column in the first row only spans one column below (colspan=1).
Here's some example markup:
Goals
Attempts
Threat <!-- this single column colspan seems to cause the problem -->
Name
Team
Stat 1
Stat 2
Stat 3
Stat 4
Stat 5
Stat 6
Stat 7
Stat 8
Stat 9
Stat 10
Stat 11
...
It looks like DataTables looks for colspan = 2 or greater to determine that the column header is a field that shouldn't be sortable when clicked on. Is there any way to have it ignore headers that have an effective colspan of 1? I tried adding colspan="1" but that didn't work.
The error I get is:
/js/dataTables-1.7/media/js/jquery.dataTables.js:5578DataTables warning: Unexpected number of TD elements. Expected 2436 and got 2262. DataTables does not support rowspan / colspan in the table body, and there must be one cell for each row/column combination.
/js/dataTables-1.7/media/js/jquery.dataTables.js:719TypeError: Result of expression 'sData' [undefined] is not an object.
I've checked that numbers of tds etc is correct.
Here's some example markup:
Goals
Attempts
Threat <!-- this single column colspan seems to cause the problem -->
Name
Team
Stat 1
Stat 2
Stat 3
Stat 4
Stat 5
Stat 6
Stat 7
Stat 8
Stat 9
Stat 10
Stat 11
...
It looks like DataTables looks for colspan = 2 or greater to determine that the column header is a field that shouldn't be sortable when clicked on. Is there any way to have it ignore headers that have an effective colspan of 1? I tried adding colspan="1" but that didn't work.
The error I get is:
/js/dataTables-1.7/media/js/jquery.dataTables.js:5578DataTables warning: Unexpected number of TD elements. Expected 2436 and got 2262. DataTables does not support rowspan / colspan in the table body, and there must be one cell for each row/column combination.
/js/dataTables-1.7/media/js/jquery.dataTables.js:719TypeError: Result of expression 'sData' [undefined] is not an object.
I've checked that numbers of tds etc is correct.
This discussion has been closed.
Replies
This is most definitely something which on the list of future enhancements. Sorry I can't be of much more use at the moment!
Regards,
Allan
How does it detect and exclude columns with colspan=2 or greater? I was wondering if I could extend that condition to columns that are explicitly set to colspan=1 to get around the limitation.
Regards,
Allan
if ( !iColspan || iColspan===0 )
{
iColumnShifted = fnShiftCol( aLayout, i, iColumn );
aLayout[i][iColumnShifted] = (nTds[j].nodeName.toUpperCase()=="TD") ? TDELEM : nTds[j];
if ( iRowspan || iRowspan===0 )
{
for ( k=1 ; k
Allan