help needed with exporting (TO DELETE)

help needed with exporting (TO DELETE)

jp_noronhajp_noronha Posts: 59Questions: 0Answers: 0
edited September 2011 in TableTools
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]

Replies

  • jp_noronhajp_noronha Posts: 59Questions: 0Answers: 0
    edited September 2011
    After a litle more debigging a stoped here:

    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
  • jp_noronhajp_noronha Posts: 59Questions: 0Answers: 0
    opsss... ound the problem... my fault, i didn't watch what i was doing when i was copying and pasting

    sorry for the mess :S
  • jp_noronhajp_noronha Posts: 59Questions: 0Answers: 0
    Allan, can you confirm to me if is there a real need to overrride completely fnClick and fnComplete functions and repeat the same code datatable has so that everythingis in order to work?

    I ask this because i prefer not alter outside scripts (less headache to manage upgrades)

    thks in advance.
    Joao Noronha
  • allanallan Posts: 61,734Questions: 1Answers: 10,110 Site admin
    Hi Joao,

    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
  • jp_noronhajp_noronha Posts: 59Questions: 0Answers: 0
    Hi 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).
  • allanallan Posts: 61,734Questions: 1Answers: 10,110 Site admin
    mColumns can either be an array of column indexes, or the string "visible" or "hidden" - the latter meaning that the column which will be exported will be reflected by the current state of the table as a result of any ColVis interaction.

    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
This discussion has been closed.