Save to CSV/Excel/PF not working when using $('.dataTable').dataTable

Save to CSV/Excel/PF not working when using $('.dataTable').dataTable

soomonsoomon Posts: 5Questions: 0Answers: 0
edited October 2013 in TableTools
Hi there,

I have to admit I'm pretty new to DataTables and TableTools, but I worked myself through it till now.
Sadly, I encountered a Strange problem I cant solve myself.

When I use:
[code]
$('#example').dataTable( {
{
'sDom': 'fT<"clear">lrtip',
"sPaginationType": "full_numbers",
"bPaginate":true,
"aaSorting": [[ 0, "asc" ]],
"oTableTools": {
"aButtons": [
"copy",
"print",
{
"sExtends": "collection",
"sButtonText": "Save",
"aButtons": [ "csv", "xls", "pdf" ]
}
],
"sSwfPath": "3rd-party-addons/datatables/extras/TableTools/media/swf/copy_csv_xls_pdf.swf",
}
}
);
[/code]
The buttons work. But I won't know how many tables I will have on the page so I need to define that for all tables on that site.
As I dont want to override all the table defaults using the .DEFAULTS stuff I want to do it using a class.

When I use:
[code]
$('.dataTable').dataTable(
{
'sDom': 'fT<"clear">lrtip',
"sPaginationType": "full_numbers",
"bPaginate":true,
"aaSorting": [[ 0, "asc" ]],
"oTableTools": {
"aButtons": [
"copy",
"print",
{
"sExtends": "collection",
"sButtonText": "Save",
"aButtons": [ "csv", "xls", "pdf" ]
}
],
"sSwfPath": "3rd-party-addons/datatables/extras/TableTools/media/swf/copy_csv_xls_pdf.swf",
}
}
);
[/code]
They dont work on all tables except the Print button.
The sSwfPath has to be correct as it works when I use IDs instead of classes. But why??
Additionally, my button definition only works on the first table.
The 2nd table (till now I only got 2) displays the default buttons ( Copy, CSV, Excel, PDF, Print ) without any grouping :/

FYI, i'm applying this to a table within the page. The page is created with PHP, but as far as DataTables is concerned, it's just a normal table created with:


Any help is greatly appreciated.

Thanks,
soomon

--

I ran the debugger and the initialization parameters for table 2 is TOTALLY different o_0
I have no idea why...
You can see the debug info here: http://debug.datatables.net/inexer

I also tried using DataTables live but without any success. Maybe it' sjust too late at night. I cant see any error there:
http://live.datatables.net/iwumet/2/edit#javascript,html,live

Today I found out that this problem starts to appear as soon as I initialize more then 1 table. When I use the class and only 1 table uses the class, it's not a problem. When 2 tables with the same class appear, it gets screwed up.

Does anybody know why that is?

Replies

  • soomonsoomon Posts: 5Questions: 0Answers: 0
    edited October 2013
    Dies anyone have an idea what I am doing wrong?
    even when I only use
    [code]
    $('.dataTable').dataTable(
    {
    'sDom': 'fT<"clear">lrtip',
    "oTableTools": {
    "sSwfPath": "3rd-party-addons/datatables/extras/TableTools/media/swf/copy_csv_xls_pdf.swf"
    }
    }
    );
    [/code]
    it's not working.
    So as soon as I initialize DataTables with a class and have more than 1 table with the same class, I am screwed.
    It's only the DataTable part thet screws up.
  • allanallan Posts: 63,489Questions: 1Answers: 10,470 Site admin
    Seems to work okay for me here: http://live.datatables.net/avacet/edit#javascript,html . Possibly try updating to TableTools 2.1.5 - although I doubt that will fix it.. Can you link us to the page?

    Allan
  • soomonsoomon Posts: 5Questions: 0Answers: 0
    hi allan,

    as I meantioned in my post.. that stops working as soon as you add a SECOND table!
    i added a second table to your example and voila:
    http://live.datatables.net/avacet/2/edit

    can anyone please help me with this?
  • allanallan Posts: 63,489Questions: 1Answers: 10,470 Site admin
    It looks like the settings from the oTableTools option isn't being applied to the second table. I'll need to look into this can get back to you. Hopefully let on today, but there a large pile of stuff to do, so possibly tomorrow.

    Allan
  • soomonsoomon Posts: 5Questions: 0Answers: 0
    Dear Allan,

    yes it seems from the 2nd table on settings dont get applied any more.
    it would be great it you could look into that.

    thanks in advance!
  • soomonsoomon Posts: 5Questions: 0Answers: 0
    Des Allan,

    did you have any chance to look at this?
  • allanallan Posts: 63,489Questions: 1Answers: 10,470 Site admin
    Not yet sorry. A bit overwhelmed with things to do at the moment.

    Allan
This discussion has been closed.