TableTools buttons not working (except Print) on one table.
TableTools buttons not working (except Print) on one table.
AndyF
Posts: 6Questions: 0Answers: 0
I have used dataTables and tableTools in an application that uses tabs to show a few different tables. I got the first table to work independently then moved on to the second one. This one automatically had all the same settings and thus worked perfectly. The third one however, doesn't let me click any other button except print (dataTables still works fine, just not tableTools).
I know the main issue is normally the file path to the swf file, but I have set this and it works on the other two tables, (I can download as pdf etc) so surely that isn't the issue.
Something to note is I get four of these errors in my console when I open the third tab/table, yet the other tables do not give this error.
[code]SCRIPT438: Object doesn't support property or method 'clearText'
ZeroClipboard.js, line 306 character 5[/code]
I had to manually include ZeroClipboard.js to get the first table working, as it wasn't working before that (not sure if this affects anything)
Update: After more testing it isn't necessarily the 3rd table that doesn't work. It seems that when I control f5, the first table I try to use the buttons on will work, and so will the second, but the 3rd will not work, regardless of what order I try them in. I can only assume this is an issue with my javascript?
I know the main issue is normally the file path to the swf file, but I have set this and it works on the other two tables, (I can download as pdf etc) so surely that isn't the issue.
Something to note is I get four of these errors in my console when I open the third tab/table, yet the other tables do not give this error.
[code]SCRIPT438: Object doesn't support property or method 'clearText'
ZeroClipboard.js, line 306 character 5[/code]
I had to manually include ZeroClipboard.js to get the first table working, as it wasn't working before that (not sure if this affects anything)
Update: After more testing it isn't necessarily the 3rd table that doesn't work. It seems that when I control f5, the first table I try to use the buttons on will work, and so will the second, but the 3rd will not work, regardless of what order I try them in. I can only assume this is an issue with my javascript?
This discussion has been closed.
Replies
When you make the element visible you need to call fnResizeButtons: http://datatables.net/extras/tabletools/api#fnResizeButtons
Failing that, please give us a link :-)
Allan
Here is my hack:
change flash creation art in _fnCreateButton function from
[code]
if ( oConfig.sAction.match(/flash/) )
{
this._fnFlashConfig( nButton, oConfig );
}
[/code]
to
[code]
if ( oConfig.sAction.match(/flash/) )
{
var that = this;
var initFlash = function() {
that._fnFlashConfig(nButton, oConfig);
};
if(!$(that.dom.table).is(':visible')) {
var functionWaitAndRun = function() {
var id = window.setInterval(function() {
if (!$(that.dom.table).is(':visible')) {
return;
}
initFlash();
window.clearInterval(id);
}, 500);
};
functionWaitAndRun();
} else {
initFlash();
}
}
[/code]
dirty, but will work even if you will forget about this issue.
Maybe we could set this loop somewhere else for entire plaggin, not for each "flash" button.
Small update: moved this hack to constructor at the end of _fnConstruct
[code]
var $element = $(this.dom.table);
if (!$element.is(':visible')) {
var functionWaitAndRun = function() {
var id = window.setInterval(function() {
if (!$element.is(':visible')) {
return;
}
if (that.fnResizeRequired()) {
/* A resize of TableTools' buttons and DataTables' columns is only required on the
* first visible draw of the table
*/
$element.dataTable().fnAdjustColumnSizing();
that.fnResizeButtons();
}
window.clearInterval(id);
}, 500);
};
functionWaitAndRun();
}
[/code]
but thanks for the reply anyway! Glad it worked for you.