$(document).ready( function () {
TableTools.DEFAULTS.aButtons = [ "copy", "csv", "xls", "pdf" ];
TableTools.DEFAULTS.sSwfPath = "../TableTools-2.0.0/media/swf/copy_cvs_xls_pdf.swf";
$("#table1, #table2, #table3").dataTable({
"bJQueryUI": true,
"sDom": '<"H"Tfr>t<"F"ip>'
});
} );
$(document).ready( function () {
TableTools.DEFAULTS.aButtons = [ "copy", "csv", "xls", "pdf" ];
TableTools.DEFAULTS.sSwfPath = "../TableTools-2.0.0/media/swf/copy_cvs_xls_pdf.swf";
$("#table1").dataTable({
"bJQueryUI": true,
"sDom": '<"H"Tfr>t<"F"ip>'
});
$(" #table2").dataTable({
"bJQueryUI": true,
"sDom": '<"H"Tfr>t<"F"ip>'
});
$("#table3").dataTable({
"bJQueryUI": true,
"sDom": '<"H"Tfr>t<"F"ip>'
});
} );
Gust said: I have bit of difficulty to find the relative example where you need to have TableTool to work on different table...
Gust said: Can you help by showing a DTs init example some how?
/*
* Example initialisation
*/
$(document).ready( function () {
$('#example').dataTable( {
"sDom": 'T<"clear">lfrtip',
"oTableTools": {
"sSwfPath": "/swf/copy_cvs_xls_pdf.swf"
}
} );
} );
</style>
everything is imported properly....
</style>
<h2>{{=page_title}}{{=table_name}}</h2>
<br/><br/>
<div id="demo">
<div id="tabs">
<!--<ul>
<li><a href="#tabs-1">{{=T('Tab1')}}</a></li>
<li><a href="#tabs-2">{{=T('Tab2')}}</a></li>
</ul>-->
<h3>{{=T('Tab1')}}</h3>
<div id="tabs-1">
{{=table1}}
</div>
<br/><br/>
<h3>{{=T('Tab2')}}</h3>
<div id="tabs-2">
{{=table2}}
</div>
</div>
</div>
ALL JS DEPENDENCIES ARE IMPORTED CORRECTLY NO SPACE TO PUT EVERYTHING...
<script type="text/javascript" charset="utf-8">
TRYED THIS INIT WITH TABS NOT WORKING
/*$(document).ready(function() {
$("#tabs").tabs( {
"show": function(event, ui) {
var oTable = $('div.dataTables_scrollBody>table.sortable', ui.panel).dataTable();
if ( oTable.length > 0 ) {
new FixedColumns( oTable, {
"iLeftColumns": 1,
//"iLeftWidth": 150
} );
//$('td', oTable.fnGetNodes()).hover( function() {
// var iLeftColumns = $('td').index(this) % 0;
// var nTrs = oTable.fnGetNodes();
// $('td:nth-child('+(iLeftColumns+1)+')', nTrs).addClass( 'highlighted' );
//}, function() {
// $('td.highlighted', oTable.fnGetNodes()).removeClass('highlighted');
//} ); // Not working properly
//oTable.fnAdjustColumnSizing();
}
}
} );
var filename_export = "{{=request.args(0)+request.now.strftime('_%Y-%m-%d_%H-%M-%S-%f')}}"
var sSwfPath_location = "{{=URL('static','plugin_added/DataTables-1.8.1/extras/TableTools/media/swf/copy_cvs_xls_pdf.swf')}}"
$('table.sortable').dataTable( {
"bJQueryUI": true,
"bAutoWidth": false,
"bScrollInfinite": true,
"sScrollY": "300px",
"sScrollX": "100%",
"bPaginate": false,
"bProcessing": true,
"bSortClasses" : false,
"sDom": '<"H"Tfr>t<"F"ip>',
"oTableTools": {
"sRowSelect": "multi", // It copy all rows anyway?? + Glitch if fixedcolumn : NEED "bSelectedOnly": true
"aButtons": [
{
"sExtends": "copy",
"bSelectedOnly": true,
"sCharSet": "utf16le"
},
{
"sExtends": "csv",
"sFieldBoundary": '"',
//"sFieldSeperator": "-",
"bSelectedOnly": true,
"sCharSet": "utf16le",
"sFileName": filename_export + ".csv"
},
{
"sExtends": "xls",
"sFieldBoundary": '"',
//"sFieldSeperator": "-",
"bSelectedOnly": true,
"sCharSet": "utf16le",
"sFileName": filename_export + ".csv"
},
{
"sExtends": "pdf",
"sPdfSize": "tabloid",
"sPdfOrientation": "landscape",
"sPdfMessage": "Your custom message would go here.",
"bSelectedOnly": true,
"sCharSet": "utf16le",
"sFileName": filename_export + ".pdf"
}
],
"sSwfPath": sSwfPath_location
},
"oLanguage": {
"sSearch": "Search:"
},
"aoColumnDefs": [
{ "sWidth": "10%", "aTargets": [ -1 ] }
]
} );
} );*/
TRYED DIFFERENTS THINGS
/*$(document).ready(function() {
$("#tabs").tabs( {
"show": function(event, ui) {
var oTable = $('div.dataTables_scrollBody>table.sortable', ui.panel).dataTable();
if ( oTable.length > 0 ) {
new FixedColumns( oTable, {
"iLeftColumns": 1,
//"iLeftWidth": 150
} );
//$('td', oTable.fnGetNodes()).hover( function() {
// var iLeftColumns = $('td').index(this) % 0;
// var nTrs = oTable.fnGetNodes();
// $('td:nth-child('+(iLeftColumns+1)+')', nTrs).addClass( 'highlighted' );
//}, function() {
// $('td.highlighted', oTable.fnGetNodes()).removeClass('highlighted');
//} ); // Not working properly
//oTable.fnAdjustColumnSizing();
}
}
} );*/
LAST IMPLEMENTATION WITHOUT TABS AND A PER TABLE INIT AS FAR AS I UNDERSTAND
$(document).ready( function () {
var sSwfPath_location = "{{=URL('static','plugin_added/DataTables-1.8.1/extras/TableTools/media/swf/copy_cvs_xls.swf')}}"
var filename_export = "{{=request.args(0)+request.now.strftime('_%Y-%m-%d_%H-%M-%S-%f')}}"
TableTools.DEFAULTS.aButtons = [
{
"sExtends": "copy",
"sCharSet": "utf16le",
"bSelectedOnly": true
},
{
"sExtends": "csv",
"sFieldBoundary": '"',
//"sFieldSeperator": "-",
"sCharSet": "utf16le",
"sFileName": filename_export + ".csv",
"bSelectedOnly": true
},
{
"sExtends": "xls",
"sFieldBoundary": '"',
//"sFieldSeperator": "-",
"sCharSet": "utf16le",
"sFileName": filename_export + ".csv",
"bSelectedOnly": true
},
/*{
"sExtends": "pdf",
"sPdfSize": "tabloid",
"sPdfOrientation": "landscape",
"sPdfMessage": "Your custom message would go here.",
"sCharSet": "utf16le",
"sFileName": filename_export + ".pdf",
"bSelectedOnly": true
}*/
];
TableTools.DEFAULTS.sSwfPath = sSwfPath_location;
TableTools.DEFAULTS.sRowSelect = "multi";
var oTable1 = $('#table1').dataTable( {
"bJQueryUI": true,
"bAutoWidth": false,
"bScrollInfinite": true,
"sScrollY": "300px",
"sScrollX": "100%",
"bPaginate": false,
"bProcessing": true,
"bSortClasses" : false,
"sDom": '<"H"Tfr>t<"F"ip>',
} );
var oTable2 = $('#table2').dataTable( {
"bJQueryUI": true,
"bAutoWidth": false,
"bScrollInfinite": true,
"sScrollY": "300px",
"sScrollX": "100%",
"bPaginate": false,
"bProcessing": true,
"bSortClasses" : false,
"sDom": '<"H"Tfr>t<"F"ip>',
} );
//var TableTools1 = TableTools.fnGetInstance( 'example1' );
new FixedColumns( oTable1, {
"iLeftColumns": 1,
//"iLeftWidth": 150
} );
new FixedColumns( oTable2, {
"iLeftColumns": 1,
//"iLeftWidth": 150
} );
} );
I ALSO TRY TO INIT TABS FROM BASIC jQUERY TABS PLUGINS SYNTAX...
/*$(function() {
var $tabs = $( "#tabs" ).tabs();
//$tabs.tabs('select', {{=request.args(0)}});
// return false;
});*/
</script>
I use Web2py so that why you have imbeded {{=SOMETHING}} sometimes...
Thanks
Width": 150
} );
} );
I ALSO TRY TO INIT TABS FROM BASIC jQUERY TABS PLUGINS SYNTAX...
/*$(function() {
var $tabs = $( "#tabs" ).tabs();
//$tabs.tabs('select', {{=request.args(0)}});
// return false;
});*/
</script>
It appears that if a DataTable is initialized in a div that is hidden, TableTools will not work on that table once it is visible.
<DIV id="datatablesTableDIV" style="display:none;"> <TABLE id="datatablesTableID"> </TABLE> </DIV>
var jqTable = $('datatablesTableID');
if ( jqTable.length > 0 ) {
var oTableTools = TableTools.fnGetInstance( jqTable[0] );
if ( oTableTools != null && oTableTools.fnResizeRequired() )
{
/* A resize of TableTools' buttons and DataTables' columns is only required on the
* first visible draw of the table
*/
jqTable.dataTable().fnAdjustColumnSizing();
oTableTools.fnResizeButtons();
}
}
$("table[id^='tab_case_']").dataTable({
with this tablestools's button params
"oTableTools": {
"sSwfPath": "/js/dataTable/extras/TableTools/swf/copy_cvs_xls_pdf.swf",
"sRowSelect": "multi",
"aButtons": [
{
"sExtends":"text",
"sButtonText": "",
"sButtonClass": 'info_class',
"sButtonClassHover": 'info_class',
"fnMouseover":function ( nButton, oConfig, oFlash ) {
jQuery(this).removeClass('ui-button ui-state-default ui-state-hover DTTT_button');
},
"fnMouseout": function ( nButton, oConfig, oFlash ) {
jQuery(this).removeClass('ui-button ui-state-default ui-state-hover DTTT_button');
}
},
{
"sExtends": "copy",
"sButtonText": "Copia",
"bSelectedOnly": "true",
"fnComplete": function(nButton, oConfig, flash, text) {
var
len = text.split('\n').length - 1;
plural = (len==1) ? "a" : "he";
plural2=(len==1) ? "a" : "e";
alert( <?php echo $TestiInLingua["statistiche_ebay"][$langid][69] ?> );
}
},
{
"sExtends": "csv",
"sButtonText": "CSV",
"bSelectedOnly": "true",
"sTips": ""
},
{
"sExtends": "xls",
"sButtonText": "Excel",
"bSelectedOnly": "true"
},
{
"sExtends": "pdf",
"sButtonText": "PDF",
"bSelectedOnly": "true"
}
]
The first's table buttons are correctly displayed, with correct css, correct position, etc while the other tables are not. In subsequent tables there are default buttons and it seems to ignore the "aButtons": [ options
$("table[id^='tab_case_']").dataTable({
with
jQuery("table[id^='tab_case_']").each(function(){
$(this).dataTable({
It looks like you're new here. If you want to get involved, click one of these buttons!
Get useful and friendly help straight from the source.