[1.7.5] Nested dataTables cause "sData is undefined" error

[1.7.5] Nested dataTables cause "sData is undefined" error

vicayavicaya Posts: 14Questions: 0Answers: 0
edited February 2011 in Bug reports
Tried to embed a dataTables in the TDs of another dataTables, it causes 'g is undefined" in jquery.dataTables.min.js and 'sData is undefined' in uncompressed version. EDIT: changed category to "bug reports".

The following is an HTML 4.01 strict (validated) page to demonstrate the problem.
[code]
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">



Test DataTables












$(function() {
$('#t2').dataTable({bJQueryUI:true, sDom:'t',aoColumns:[null, {bSortable:false, bSearchable:false}]}).fnSetFilteringDelay(288);
$('#t3').dataTable({bJQueryUI:true, sDom:'t'}).fnSetFilteringDelay(288);
$('#t4').dataTable({bJQueryUI:true, sDom:'t'}).fnSetFilteringDelay(288);
});



Nested tables






Column1

Column2



r1





SubColumn1

SubColumn2



subc1r1

subc2r1


subc1r2

subc2r2




r2





SubColumn1

SubColumn2



subc1r1

subc2r1


subc1r2

subc2r2







[/code]

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Hi vicaya,

    I've got to admit - I'm really surprised that this validates given that there are no closing tags on the table! That's absolutely amazing in fact...

    However, the problem comes from this:

    [code]



    r1
    [/code]
    DataTables currently doesn't allow TH elements in the TBODY. It will in future, but not yet I'm afraid. If you change that TH to a TD it will work as expected. You can add a class to the new TD element to style it like a TH if you want.

    Regards,
    Allan
  • vicayavicaya Posts: 14Questions: 0Answers: 0
    In real html (unlike its bastard sibling xhtml), tr/th/td closing tags are optional just like li, according to the DTD.

    > DataTables currently doesn't allow TH elements in the TBODY.

    Anywhere (all descendants) in the TBODY? Because an embedded dataTables needs TH? or is TD in THEAD good enough?
  • vicayavicaya Posts: 14Questions: 0Answers: 0
    I just tested with TH changed to TD, while leaving the TH in the sub-dataTables intact. It worked. Thanks!
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Just direct children of TR elements in TBODY need to be TD elements - in the THEAD / TFOOT you can put in more or less what you want, as long as there is at least one unique TH element for each column.

    I always write HTML in HTML 4 strict, but with closing tags - I didn't realise you could write a table without closing tags. I like that trick - might be very useful for where the odd byte is important with bandwidth - thanks for the heads up :-)

    Allan
  • ultrageoffultrageoff Posts: 3Questions: 0Answers: 0
    Just to mention, I got 'sdata is undefined' (and similar, but not identical, with the minified script) as a result of a spurious td tag. Took it out and all has been wonderful since - so I'd definitely want to check table structures thoroughly if that sort of problem came up.
This discussion has been closed.