TableTools breaks DataTables when set as "sDom" default

TableTools breaks DataTables when set as "sDom" default

drakejdrakej Posts: 11Questions: 0Answers: 0
edited February 2014 in TableTools
Not sure if this should go in Bug Reports or here but since it's specific to TableTools I chose here.

When I attempt to initialize a table with .dataTable(); and no other arguments (all defaults) I get an error:

"Cannot read property 'tableTools' of null"

The source of this error is based on how I have dataTables defaults configured. I override the "sDom" property using $.extend( true, $fn.dataTable.defaults, {"sDom": "T"}}); for example.

The problem is that when I have TableTools as a default "sDom" option, I get this error if I don't explicitly initialize dataTables with a config object. So calling $('#some_table').dataTable(); results in the error above. If I call it with $('#some_table').dataTable(); there's no error.

It's a rather minor bug but the source of the problem suggests that TableTools expects the dataTable to explicitly have that configuration object at all times, even before dataTables actually generates it when the initialization doesn't include it.

Hope that makes sense, if you need more information just ask.

Replies

  • allanallan Posts: 63,489Questions: 1Answers: 10,470 Site admin
    Can you please link me to a test page showing the error? I've just thrown together this page, showing sDom default being set with `Tt` and it works okay: http://live.datatables.net/gomupeb/1/edit

    Allan
  • drakejdrakej Posts: 11Questions: 0Answers: 0
    I was targeting 1.9.4, so I think that's why you don't get the error. Your example is using the nightly build so you might have fixed it already. Just in case I did throw up an example using version 1.9.4 of DataTables and 2.2.0 of TableTools:

    https://www.drakej.com/datatables.html
  • allanallan Posts: 63,489Questions: 1Answers: 10,470 Site admin
    Thanks very much for this - you are absolutely correct. In 1.9.4 if you don't pass any parameters into the DataTables constructor, the options parameter held internally is null and we get a JS error. That isn't the case in 1.10.

    So a bug in TableTools which should handle both forms. Fix is committed here: https://github.com/DataTables/TableTools/commit/6e97760a

    And it is now in the nightly. Updated example using 1.9.4 showing it working now: http://live.datatables.net/valugin/1/edit

    Thanks again for flagging this up and providing the details!

    Regards,
    Allan
This discussion has been closed.