Problem with ColVis

Problem with ColVis

wengolewengole Posts: 6Questions: 0Answers: 0
edited March 2012 in DataTables 1.9
Hi,

I'm trying to make use of ColVis to allow the user to hide/show columns, however it's generating a JS error whenever I deselect a column. I'm almost certain this is something I'm doing wrong, as for a start I have quite a complicated sDom setting.

The error I get is:
[code]
Uncaught TypeError: Cannot call method 'substring' of null 192.168.2.112/calls/list/#:474
$.dataTable.fnRowCallback 192.168.2.112/calls/list/#:474
L 192.168.2.112/static/js/dataTables/dataTables_1.9.0.js:98
H 192.168.2.112/static/js/dataTables/dataTables_1.9.0.js:38
Ra 192.168.2.112/static/js/dataTables/dataTables_1.9.0.js:49
b 192.168.2.112/static/js/dataTables/dataTables_1.9.0.js:46
m.defaults.fnServerData.o.jqXHR.i.ajax.success 192.168.2.112/static/js/dataTables/dataTables_1.9.0.js:132
f.Callbacks.n 192.168.2.112/static/js/jquery-min.js:2
f.Callbacks.o.fireWith 192.168.2.112/static/js/jquery-min.js:2
w 192.168.2.112/static/js/jquery-min.js:4
f.support.ajax.f.ajaxTransport.send.d 192.168.2.112/static/js/jquery-min.js:4
[/code]

I've also made use of the superb DataTables Debugger: http://debug.datatables.net/iqoned

Any pointers will be greatly appreciated.

Replies

  • allanallan Posts: 63,692Questions: 1Answers: 10,500 Site admin
    Hi,

    Thanks very much for providing the debug trace - really helpful!

    I suspect that the issue is in your fnRowCallback function here:

    [code]
    var recording = $('td:nth-child(13)', nRow).html();
    if(recording != ''){
    var visibleText = recording.substring(0,25);
    [/code]

    If you remove a column with ColVis is there still 13 or more columns in the table (baring in mind that DataTables will remove from the DOM columns which aren't visible)? I'm going to guess not. I think what you might want to do is use the data (second parameter into fnRowCallback) rather than querying the DOM.

    Allan
  • wengolewengole Posts: 6Questions: 0Answers: 0
    Hi Allan,

    Yes that was the problem. Thanks again for your excellent support. I have another issue, but I'll open another discussion for that.
This discussion has been closed.