How can I programmatically close the print view?

How can I programmatically close the print view?

edtdedtd Posts: 4Questions: 0Answers: 0
edited January 2011 in TableTools
Is there a way to programmatically close the print view and return to the normal view? I found the _fnPrintEnd() function, but I'm not sure how I can call it from my DataTable object...

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    You could get the TableTools instance object by using fnGetInstance ( http://datatables.net/extras/tabletools/api#fnGetInstance ) and then calling _fnPrintEnd() on that. Not though that _fnPrintEnd() is a private function (donated by the underscore) so it is possible it will change between versions - but I don't see that happening any time soon!

    Regards,
    Allan
  • toxaustoxaus Posts: 3Questions: 0Answers: 0
    Hi, guys.
    Allan, seems i found some wrong behavior in TableTools:
    i have datatble (#pricelist) with
    [code]
    "sDom" : 'rt<"table_length"l>i<"pagination"p>',
    [/code]
    when i initialize Tabletools like

    [code]
    oTable = $('#pricelist').dataTable({...});

    var oTableTools = new TableTools( oTable, {
    "aButtons": [
    {
    "sExtends": "xls",
    "sButtonText": "<?=__("HP Button0083")?>"
    }
    , {
    "sExtends": "print"
    , "bShowAll": false
    , "sMessage": ''
    , "fnClick": function ( nButton, oConfig, oFlash ) {
    $('#print_head').html($('#print_head_hidden').html());
    }
    }
    ],
    "sSwfPath": "/images/copy_cvs_xls.swf"
    });

    [/code]
    and after i just append it to my table
    [code]
    $('#xls').append( oTableTools.dom.container );
    [/code]

    It Works fine, but when i want to add some button to print_preview , using
    [code]
    TableTools.fnGetInstance('pricelist')._fnPrintEnd(true);
    [/code]

    i have nothing. Seems, if I don't use T in sDom i can't get
    instance of my table via
    [code]
    var TableTools1 = TableTools.fnGetInstance( 'example1' );
    [/code]
    This return null, because (investigated it)
    [code]
    TableTools._aInstances.length
    [/code]
    equal 0...

    What you mean about it. I did something wrong or it's a bug of plugin?

    By the way, thank you for your good thing that you made!
  • toxaustoxaus Posts: 3Questions: 0Answers: 0
    Found the way to win this thing - just make button with onclick behavior like
    [code]
    oTableTools._fnPrintEnd(e)
    [/code]
    Not sure that it is so right way, but it is works fine =)
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Yup - I'd say that way is the correct way (albeit calling a private function :-) ).

    Allan
This discussion has been closed.