Save to CSV/Excel/PF not working when using $('.dataTable').dataTable
Save to CSV/Excel/PF not working when using $('.dataTable').dataTable
soomon
Posts: 5Questions: 0Answers: 0
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?
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?
This discussion has been closed.
Replies
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.
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?
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!
did you have any chance to look at this?
Allan