help needed with exporting (TO DELETE)
help needed with exporting (TO DELETE)
jp_noronha
Posts: 59Questions: 0Answers: 0
Can anyone tell me what is wrong with this code?
I'm trying to export a table with grouped columns, which are hidden. but allthought exporting seems to work, shows no errors and is behavior is what i expect (by showing and hiding the group columns during the process), when i open the file it's empty.
I use IE8, with datatable client-side processing, all jquery script is injected during the post as needed building the code below.
i really really need this to work. help is appreciated :)
Joao Noronha
[code]
var oDTctl00_ContentPlaceHolder1_GridVolNegocioDet = $('#ctl00_ContentPlaceHolder1_GridVolNegocioDet').dataTable({
"bJQueryUI": false
, "bSortClasses ": false
, "bDeferRender": true
, "iDeferLoading": 366
, "bProcessing": true
, "aaSorting": []
, "oLanguage": {
"sProcessing": "Processando...",
"sLengthMenu": "Mostrar _MENU_ registros",
"sEmptyTable ": "Não foram encontrados resultados",
"sZeroRecords": "Não foram encontrados resultados",
"sInfo": "Mostrando de _START_ até _END_ de _TOTAL_ registros",
"sInfoEmpty": "Mostrando de 0 até 0 de 0 registros",
"sInfoFiltered": "(filtrado de _MAX_ registros no total)",
"sInfoPostFix": "",
"sInfoThousands": ".",
"sSearch": "Buscar:",
"sUrl": "",
"oPaginate": {
"sFirst": "",
"sPrevious": "",
"sNext": "",
"sLast": ""
}
}
, "aoColumnDefs": [
{
"bSortable": false, "aTargets": [ 0,1 ]
}
, {
"sWidth": "300", "aTargets": [ 2 ]
}
]
, "bStateSave": true
, "iCookieDuration": 60*60*12
, "bPaginate": false, "bLengthChange": false
, "sDom": 'RCTV<"clear">lfrtip'
, "oColReorder": {
"aiOrder": [0,1,2,3,4,5,6,7,8,9]
}
, "oColVis": {
"buttonText": "Colunas", "bRestore": true, "sRestore": "Restaurar", "sAlign": "right", "sSize": "css", "activate": "mouseover"
, "aiExclude": [ 0,1 ]
}
, "oTableTools": {
"sSwfPath": "../scripts/jquery/js/../swf/copy_cvs_xls_pdf.swf",
"aButtons": [
{
"sExtends": "print", "sButtonText": "Impressão", "mColumns": "visible", "sToolTip": "Impressão",
"sMessage": "",
"sInfo": "ImpressaoPor favor utilizar a funcionalidade de impressão do browser para imprimir esta tabela. Pressione ESC (escape) quando terminar."
}
, {
"sExtends": "copy", "sButtonText": "Clipboard", "mColumns": "visible", "fnClick": function ( nButton, oConfig, oFlash ) {
oDTctl00_ContentPlaceHolder1_GridVolNegocioDet.fnSetColumnVis( 0, true );
oDTctl00_ContentPlaceHolder1_GridVolNegocioDet.fnSetColumnVis( 1, true );
this.fnSetText( flash, this.fnGetTableData(oConfig) );
}
, "fnComplete": function ( nButton, oConfig, oFlash ) {
oDTctl00_ContentPlaceHolder1_GridVolNegocioDet.fnSetColumnVis( 0, false );
oDTctl00_ContentPlaceHolder1_GridVolNegocioDet.fnSetColumnVis( 1, false );
var lines = text.split('\n').length, len = this.s.dt.nTFoot === null ? lines-1 : lines-2, plural = (len==1) ? "" : "s";
alert( 'Copied '+len+' row'+plural+' to the clipboard' );
}
}
,
{
"sExtends": "csv", "sButtonText": "CSV", "mColumns": "visible", "bFooter": false , "bHeader": false, "fnClick": function ( nButton, oConfig, oFlash ) {
oDTctl00_ContentPlaceHolder1_GridVolNegocioDet.fnSetColumnVis( 0, true );
oDTctl00_ContentPlaceHolder1_GridVolNegocioDet.fnSetColumnVis( 1, true );
this.fnSetText( flash, this.fnGetTableData(oConfig) );
}
, "fnComplete": function ( nButton, oConfig, oFlash ) {
oDTctl00_ContentPlaceHolder1_GridVolNegocioDet.fnSetColumnVis( 0, false );
oDTctl00_ContentPlaceHolder1_GridVolNegocioDet.fnSetColumnVis( 1, false );
}
}
,
{
"sExtends": "xls", "sButtonText": "XLS", "mColumns": "visible", "sTitle": "", "fnClick": function ( nButton, oConfig, oFlash ) {
oDTctl00_ContentPlaceHolder1_GridVolNegocioDet.fnSetColumnVis( 0, true );
oDTctl00_ContentPlaceHolder1_GridVolNegocioDet.fnSetColumnVis( 1, true );
this.fnSetText( flash, this.fnGetTableData(oConfig) );
}
, "fnComplete": function ( nButton, oConfig, oFlash ) {
oDTctl00_ContentPlaceHolder1_GridVolNegocioDet.fnSetColumnVis( 0, false );
oDTctl00_ContentPlaceHolder1_GridVolNegocioDet.fnSetColumnVis( 1, false );
}
}
,
{
"sExtends": "pdf", "sButtonText": "PDF", "mColumns": "visible", "sNewLine": "auto", "sTitle": "", "fnClick": function ( nButton, oConfig, oFlash ) {
oDTctl00_ContentPlaceHolder1_GridVolNegocioDet.fnSetColumnVis( 0, true );
oDTctl00_ContentPlaceHolder1_GridVolNegocioDet.fnSetColumnVis( 1, true );
this.fnSetText(flash, "title:" + this.fnGetTitle(oConfig) + "\n" + "message:" + oConfig.sPdfMessage + "\n" + "colWidth:" + this.fnCalcColRatios(oConfig) + "\n" + "orientation:" + oConfig.sPdfOrientation + "\n" + "size:" + oConfig.sPdfSize + "\n" + "--/TableToolsOpts--\n" + this.fnGetTableData(oConfig));
}
, "fnComplete": function ( nButton, oConfig, oFlash ) {
oDTctl00_ContentPlaceHolder1_GridVolNegocioDet.fnSetColumnVis( 0, false );
oDTctl00_ContentPlaceHolder1_GridVolNegocioDet.fnSetColumnVis( 1, false );
}
}
]
}
});
oDTctl00_ContentPlaceHolder1_GridVolNegocioDet.fnSearchHighlighting();
new FixedHeader(oDTctl00_ContentPlaceHolder1_GridVolNegocioDet);
oDTctl00_ContentPlaceHolder1_GridVolNegocioDet.rowGrouping({
bSetGroupingClassOnTR: false
, iGroupingColumnIndex: 0
, bExpandableGrouping: true
, bExpandSingleGroup: true
, iExpandGroupOffset: -1
, iGroupingColumnIndex2: 1
, sGroupLabelPrefix2 : "Estab. "
});
[/code]
I'm trying to export a table with grouped columns, which are hidden. but allthought exporting seems to work, shows no errors and is behavior is what i expect (by showing and hiding the group columns during the process), when i open the file it's empty.
I use IE8, with datatable client-side processing, all jquery script is injected during the post as needed building the code below.
i really really need this to work. help is appreciated :)
Joao Noronha
[code]
var oDTctl00_ContentPlaceHolder1_GridVolNegocioDet = $('#ctl00_ContentPlaceHolder1_GridVolNegocioDet').dataTable({
"bJQueryUI": false
, "bSortClasses ": false
, "bDeferRender": true
, "iDeferLoading": 366
, "bProcessing": true
, "aaSorting": []
, "oLanguage": {
"sProcessing": "Processando...",
"sLengthMenu": "Mostrar _MENU_ registros",
"sEmptyTable ": "Não foram encontrados resultados",
"sZeroRecords": "Não foram encontrados resultados",
"sInfo": "Mostrando de _START_ até _END_ de _TOTAL_ registros",
"sInfoEmpty": "Mostrando de 0 até 0 de 0 registros",
"sInfoFiltered": "(filtrado de _MAX_ registros no total)",
"sInfoPostFix": "",
"sInfoThousands": ".",
"sSearch": "Buscar:",
"sUrl": "",
"oPaginate": {
"sFirst": "",
"sPrevious": "",
"sNext": "",
"sLast": ""
}
}
, "aoColumnDefs": [
{
"bSortable": false, "aTargets": [ 0,1 ]
}
, {
"sWidth": "300", "aTargets": [ 2 ]
}
]
, "bStateSave": true
, "iCookieDuration": 60*60*12
, "bPaginate": false, "bLengthChange": false
, "sDom": 'RCTV<"clear">lfrtip'
, "oColReorder": {
"aiOrder": [0,1,2,3,4,5,6,7,8,9]
}
, "oColVis": {
"buttonText": "Colunas", "bRestore": true, "sRestore": "Restaurar", "sAlign": "right", "sSize": "css", "activate": "mouseover"
, "aiExclude": [ 0,1 ]
}
, "oTableTools": {
"sSwfPath": "../scripts/jquery/js/../swf/copy_cvs_xls_pdf.swf",
"aButtons": [
{
"sExtends": "print", "sButtonText": "Impressão", "mColumns": "visible", "sToolTip": "Impressão",
"sMessage": "",
"sInfo": "ImpressaoPor favor utilizar a funcionalidade de impressão do browser para imprimir esta tabela. Pressione ESC (escape) quando terminar."
}
, {
"sExtends": "copy", "sButtonText": "Clipboard", "mColumns": "visible", "fnClick": function ( nButton, oConfig, oFlash ) {
oDTctl00_ContentPlaceHolder1_GridVolNegocioDet.fnSetColumnVis( 0, true );
oDTctl00_ContentPlaceHolder1_GridVolNegocioDet.fnSetColumnVis( 1, true );
this.fnSetText( flash, this.fnGetTableData(oConfig) );
}
, "fnComplete": function ( nButton, oConfig, oFlash ) {
oDTctl00_ContentPlaceHolder1_GridVolNegocioDet.fnSetColumnVis( 0, false );
oDTctl00_ContentPlaceHolder1_GridVolNegocioDet.fnSetColumnVis( 1, false );
var lines = text.split('\n').length, len = this.s.dt.nTFoot === null ? lines-1 : lines-2, plural = (len==1) ? "" : "s";
alert( 'Copied '+len+' row'+plural+' to the clipboard' );
}
}
,
{
"sExtends": "csv", "sButtonText": "CSV", "mColumns": "visible", "bFooter": false , "bHeader": false, "fnClick": function ( nButton, oConfig, oFlash ) {
oDTctl00_ContentPlaceHolder1_GridVolNegocioDet.fnSetColumnVis( 0, true );
oDTctl00_ContentPlaceHolder1_GridVolNegocioDet.fnSetColumnVis( 1, true );
this.fnSetText( flash, this.fnGetTableData(oConfig) );
}
, "fnComplete": function ( nButton, oConfig, oFlash ) {
oDTctl00_ContentPlaceHolder1_GridVolNegocioDet.fnSetColumnVis( 0, false );
oDTctl00_ContentPlaceHolder1_GridVolNegocioDet.fnSetColumnVis( 1, false );
}
}
,
{
"sExtends": "xls", "sButtonText": "XLS", "mColumns": "visible", "sTitle": "", "fnClick": function ( nButton, oConfig, oFlash ) {
oDTctl00_ContentPlaceHolder1_GridVolNegocioDet.fnSetColumnVis( 0, true );
oDTctl00_ContentPlaceHolder1_GridVolNegocioDet.fnSetColumnVis( 1, true );
this.fnSetText( flash, this.fnGetTableData(oConfig) );
}
, "fnComplete": function ( nButton, oConfig, oFlash ) {
oDTctl00_ContentPlaceHolder1_GridVolNegocioDet.fnSetColumnVis( 0, false );
oDTctl00_ContentPlaceHolder1_GridVolNegocioDet.fnSetColumnVis( 1, false );
}
}
,
{
"sExtends": "pdf", "sButtonText": "PDF", "mColumns": "visible", "sNewLine": "auto", "sTitle": "", "fnClick": function ( nButton, oConfig, oFlash ) {
oDTctl00_ContentPlaceHolder1_GridVolNegocioDet.fnSetColumnVis( 0, true );
oDTctl00_ContentPlaceHolder1_GridVolNegocioDet.fnSetColumnVis( 1, true );
this.fnSetText(flash, "title:" + this.fnGetTitle(oConfig) + "\n" + "message:" + oConfig.sPdfMessage + "\n" + "colWidth:" + this.fnCalcColRatios(oConfig) + "\n" + "orientation:" + oConfig.sPdfOrientation + "\n" + "size:" + oConfig.sPdfSize + "\n" + "--/TableToolsOpts--\n" + this.fnGetTableData(oConfig));
}
, "fnComplete": function ( nButton, oConfig, oFlash ) {
oDTctl00_ContentPlaceHolder1_GridVolNegocioDet.fnSetColumnVis( 0, false );
oDTctl00_ContentPlaceHolder1_GridVolNegocioDet.fnSetColumnVis( 1, false );
}
}
]
}
});
oDTctl00_ContentPlaceHolder1_GridVolNegocioDet.fnSearchHighlighting();
new FixedHeader(oDTctl00_ContentPlaceHolder1_GridVolNegocioDet);
oDTctl00_ContentPlaceHolder1_GridVolNegocioDet.rowGrouping({
bSetGroupingClassOnTR: false
, iGroupingColumnIndex: 0
, bExpandableGrouping: true
, bExpandSingleGroup: true
, iExpandGroupOffset: -1
, iGroupingColumnIndex2: 1
, sGroupLabelPrefix2 : "Estab. "
});
[/code]
This discussion has been closed.
Replies
code]
try {
document.getElementById("ZeroClipboardMovie_1").SetReturnValue(__flash__toXML(ZeroClipboard.dispatch("1","mouseDown",null)) );
}
catch (e) {
document.getElementById("ZeroClipboardMovie_1").SetReturnValue("");
}
[/code]
the error message says:
'flash' is not defined.
I forgot to inform that i use all nightly builds and that tha same code without fnClick woks fine
sorry for the mess :S
I ask this because i prefer not alter outside scripts (less headache to manage upgrades)
thks in advance.
Joao Noronha
If you are just wanting to modify what columns are included in the output (as it looks from your fnClick functions), then you can use the mColumns ( http://datatables.net/extras/tabletools/button_options#mColumns ) option that TableTools provides. This way there is no need to override fnClick or fnComplete to restore the state.
Allan
Correct me if i'm wrong, but if i use mColumns as an option it will fix them when exporting, and if the user as colvis as a tool to hide columns that he doesn't want to export then he can not use it.
My first thought was to do as you say, but but what i needed was to export only the visible columns and the ones hidden by the class (grouped columns).
If this isn't flexible enough for youbthere are two options:
1. It's reasonably easy to modify the TableTools source to include another string option other than "visible" etc, if you wanted to do that.
2. You could modify mColumns on the fly in an fnClick override before you call the fnGetTableData function.
Allan