newbie, trying to get table tools to work.
newbie, trying to get table tools to work.
working with rails, utilized a lot of multi-tab tables, this one doesn't need the tabs, but I like the appearance and hope to keep it..
installed the jquery-datatables-rails gem.
all requires are there...
the buttons actually worked once, but have disappeared.
I've tried a lot of conf with dom and swfpath..still confused about that, no matter what I read swfpath leads to a blank file..
my JS is
$(document).ready(function() {
$("#tabs").tabs( {
"activate": function(event, ui) {
var table = $.fn.dataTable.fnTables(true);
if ( table.length > 0 ) {
$(table).dataTable().fnAdjustColumnSizing();
}
}
} );
$('queries').dataTable( {
"sScrollY": "400px",
"bScrollCollapse": true,
"bPaginate": false,
"bJQueryUI": true,
"retrieve": true,
"aoColumnDefs": [
{ "sWidth": "10%", "aTargets": [ -1 ] }
]
responsive: true,
tableTools: {
sSwfPath: "/assets/dataTables/extras/swf/copy_csv_xls_pdf.swf"
},
dom: "B<'row'<'small-4 columns'l><'small-4 columns'f><'small-4 columns'T>r>"+
"t"+
"<'row'<'small-6 columns'i><'small-6 columns'p>>"
} );
});
and the table from my view opens up like this..
<
table cellpadding="0" cellspacing="0" border="0" class="display responsive no-wrap" id="queries">
This question has an accepted answers - jump to answer
Answers
Don't use TableTools. As its documentation notes it is retired software and has now been replaced by Buttons. Use Buttons' HTML5 export options. It is much easier.
Allan
I've tried using bower_component and npm installed versions of datatables, and datatable buttons, all correct syntax, no errors on the console at all. utilized the buttons: ['print'],
but still doesn't appear at all.
thanks though
I speculate that the reason rendering is being disrupted by one error. I'll get the pop up 'can't reinitialize datatable id='example', on every page, multiple times.
unless i implement retrieve: 'true'
i'll post a sample js
$(document).ready(function() {
$("#tabs").tabs( {
"activate": function(event, ui) {
var table = $.fn.dataTable.fnTables(true);
if ( table.length > 0 ) {
$(table).dataTable().fnAdjustColumnSizing();
}
}
} );
$('table.display').dataTable( {
"sScrollY": "400px",
"bScrollCollapse": true,
"bPaginate": false,
"bJQueryUI": true,
"retrieve": true,
"aoColumnDefs": [
{ "sWidth": "10%", "aTargets": [ -1 ] }
],
} );
} );
I'd need a link to a page showing the issue to be able to offer any help. The code you have above looks like it should show the buttons.
Allan
will pm you
Could you just PM me the user / pass please? Click my name above and then the "Send message" button.
Thanks,
Allan
Thanks for the details by PM (and keeping the server online!).
Two issues I can see:
1) The button definition files aren't being loaded. Currently for DataTables you are loading:
You need to include
buttons.print.js
if you want the print button (&c. for the other button types).2) Your DataTables initialisation is:
It doesn't include Buttons at all. See the Buttons documentation for how to use Buttons.
A possible third issue is that the combination of both jQuery UI and Zurb on the same page may cause styling conflicts, but it won't cause any issues with the functionality of the buttons once they are working.
Regards,
Allan
Thanks a ton for checking in on this! your a great help.
I do actually have the buttons: configured in my JS for queries.js, which makes me think this page is rendering another table..
i caught and added the buttons.print.js to my application.js..
renamed my #tabs div and #table.display to match the new table name..
just copied and paste the basic initialization from the site..
heres the latest config for the queries.js
heres my application.js
heres my application.css
heres the table rendered..
Unfortunately the server appears to be offline again. I'll try to take a look at it again later on.
Allan
I've got the server back up, will leave the test server running until this gets resolved. thanks!
Looks to still be the same. The table's initialisation does not include Buttons. This is the debug trace. Click the "Tables" button and then the "Initialisation options" option. You will be able to see that Buttons isn't used there.
Have a look at this example which shows how Buttons can be used with jQuery UI.
Allan
tried, the jquery ui, still nothing. really can't figure this out..
It appears the issue is that you have multiple DataTables initialisations. For example in all three of
mail_groups.self
,requests.self
andusers.self
there is:In
queries.self
where you are actually trying to add Buttons, that appears to be correctly setup (although thedom
options used won't make for a nice looking jQuery UI styled table) but that code is executing after the others.Since you have used
retrieve
if just gets the existing table! It doesn't set any options. Asretrieve
's documentation states:So the solution might be to just make your other DataTables initialisations more selective.
Allan
that was it! print button showed up!
now all I haven left to deal with is why my rows aren't being limited anymore, will start another forum for that
thanks again!