TableTools v1.0.2 - Save as Excel, CSV, copy and print! - Page 3

TableTools v1.0.2 - Save as Excel, CSV, copy and print!

1356

Replies

  • alimontialimonti Posts: 9Questions: 0Answers: 0
    In this case, maybe the problem is the Flash version.
    Try to download the last version and try again.
  • ShadokShadok Posts: 19Questions: 0Answers: 0
    I have the lastest version.
    Is there a way to enable a debug ?
  • ShadokShadok Posts: 19Questions: 0Answers: 0
    I spotted a mistake in my first post, I didn't see any mistake with Firebug (firefox extension).
  • JustLikeIcarusJustLikeIcarus Posts: 8Questions: 0Answers: 0
    Hello all,

    Is there an easy way to have the print or save as functions include the hidden columns as well? If not do you have any recommendations on doing so.?
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    @JustLikeIcarus: Line 522 "if ( _DTSettings.aoColumns[i].bVisible )" is the key here. Just remove that and it will include your hidden data. There isn't an API method to have it to this at the moment, might I will look at possibly adding one for a future release.

    Allan
  • JustLikeIcarusJustLikeIcarus Posts: 8Questions: 0Answers: 0
    Thanks Allan, that works for copy and save as. However not for print... Any recommendations here?
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Yup - you'll need to use the fnSetColumnVis ( http://datatables.net/api#fnSetColumnVis ) function to display the hidden columns. TableTools will display the table in it's current state - so you need to override that, and this function is the way to do it :-)

    Allan
  • ShadokShadok Posts: 19Questions: 0Answers: 0
    I reinstalled the plugin, using the same path as the demo and i still have empty files.
    Print tables works fine but any files export gives me an empty file (and copy to clipboard isn't working too).

    I'm using dataTables and dataTools last available version.
    Firebug reports no error.
    All files are loaded correctly.

    I only have one hundred lines.

    What am i missing ?

    Here's my code :
    [code] $(document).ready(function() {
    goTable = $('#ordersList').dataTable( {
    "bProcessing": true,
    "bServerSide": true,
    "sPaginationType" : "full_numbers",
    "sAjaxSource": "./includes/server_processing.php",
    "iDisplayLength": 25,
    "aaSorting": [[ 0, "desc" ]],
    "bAutoWidth": false,
    "aoColumns": [
    { sWidth: '30px', sClass: 'orderAction' },
    { sWidth: null, sClass: 'master' },
    { sWidth: '110px' },
    { sWidth: null },
    { sWidth: '16px' },
    { sWidth: '16px', bSortable: false },
    { sWidth: '40px', bSortable: false }
    ]
    } );

    $('#filter_norm input').keyup( fnFilterNormal );
    } );[/code]
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Hi,

    I think you need to include TableTools in the sDom parameter, as in the demo:

    [code]
    $('#example').dataTable( {
    "sDom": 'T<"clear">lfrtip'
    } );
    [/code]
    Could you provide a link to where you have having problems. Might make things easier to debug.

    Allan
  • ShadokShadok Posts: 19Questions: 0Answers: 0
    Unfortunately, I can't provide a link since it's an internal tool.
    Sorry, i pasted the wrong code, here's the one i'm using with tabletools :
    [code] $(document).ready(function() {
    goTable = $('#ordersList').dataTable( {
    "bProcessing": true,
    "bServerSide": true,
    "sPaginationType" : "full_numbers",
    "sAjaxSource": "./includes/manager.billing.php",
    "iDisplayLength": 25,
    "aaSorting": [[ 0, "desc" ]],
    "bAutoWidth": false,
    "oLanguage": {
    "sLengthMenu": "Afficher _MENU_ BC par page",
    "sZeroRecords": "Aucun r
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Hi,

    Assuming that all the resources are loading okay (probably worth checking your error log to make sure there are no 404 errors, and also the 'Net' tab in Firebug or whatever debug tool you use), then this is quite odd! With server-side processing the behaviour of TableTools is slightly different since it will only give the records which are currently on display (not sure what the print will do though!), but it should still give you your 25 records or so.

    So a couple of things to check:
    1. No 404 errors
    2. You are using Flash 10 plug-in
    3. No Javascript errors anywhere

    Regards,
    Allan
  • ShadokShadok Posts: 19Questions: 0Answers: 0
    I checked for 404 and javascript errors and everything's fine.
    I have flash version 10.0.32.18 (10.0 r32).

    Is there an easy way to enable a debug ?
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Hi,

    There isn't really any trace logging information in TableTools - given that it's meant to be nice an simple to use :-). Without being able to see what is going on, I rather suspect that you will need to dig around in the code using console.log() etc to find out what is going on. fnGetDataTablesData() is probably the best place to start.

    Regards,
    Allan
  • ShadokShadok Posts: 19Questions: 0Answers: 0
    I put an alert on sData after this line :
    sData += _DTSettings.aoData[ _DTSettings.aiDisplay[j] ]._aData[ i ].replace(/\n/g," ").replace( /<.*?>/g, "" ) +sSeperator;

    So I got one alert for each column on the first line, except for the last one (numeric column).
    I can't see why I don't get any alert for the others lines.

    allan> I may be able to give you a limited access to this part of the script but i'll need you to give me a login and password to use :)
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Hi Shadok,

    If you could, that would be most useful. You can send it to me direct using: http://datatables.net/contact .

    Regards,
    Allan
  • ShadokShadok Posts: 19Questions: 0Answers: 0
    Done :)

    Thanks.
  • hardlickhardlick Posts: 14Questions: 0Answers: 0
    Its posible, add a new feature, export to PDF?
  • ShadokShadok Posts: 19Questions: 0Answers: 0
    It's not directly possible with tableTools since PDF generation requires PHP (using TCPDF per example).
    So, tableTools would only be able to grab the data and send it (POST or GET) to a PHP script.
    Now, using TCPDF, we know that an 14 page width is 192 (i never found which unity was using tcpdf).
    It's easy to know how many columns are to print on the page.
    The main problem would be to calculate the column size (doing 192 divided by the number of columns wouldn't always work).
    Otherwise, it would be a piece of cake.
  • ShadokShadok Posts: 19Questions: 0Answers: 0
    Sinece you already have an xls or csv file, it's already easy to convert it to pdf (using a virtual printer or openOffice)
  • hardlickhardlick Posts: 14Questions: 0Answers: 0
    Thanks for the anwers, yes i have use a class for export to pdf, dompdf, but muy question was if inside the block of box (copy to clipboard, export to csv, etc), i can add a new box, for export to pdf with an image as the others. i'll have to change the flash file?
  • ShadokShadok Posts: 19Questions: 0Answers: 0
    No.
    Use the jSon data returned by the call to server_processing.php (with fnServerData by example) and send it to your php script (simply alter the js file to add your button).
  • hardlickhardlick Posts: 14Questions: 0Answers: 0
    thanks for your answer.. but what js file? ZeroClipboard.js? in what part for add a new button?, thanks a lot,
  • ShadokShadok Posts: 19Questions: 0Answers: 0
    tableTools.js

    You can take fnFeaturePrint as example.
  • hardlickhardlick Posts: 14Questions: 0Answers: 0
    edited September 2009
    Thanks, now i add a new function for expor to pdf, but one more question, how i pass a data (url) to TableTools.js from $('#example').dataTable({ }) ?..
    for example i want to pass:
    olisttable = $('#example').dataTable({
    "iDisplayLength": 10,
    "bAutoWidth":false,
    "bJQueryUI": true,
    "sUrlPDF":"/files/exportpdf.php", // add this parameter for send a url for export to pdf
    "sPaginationType": "full_numbers",
    "sDom": 'T<"fg-toolbar ui-widget-header ui-corner-tl ui-corner-tr ui-helper-clearfix"lfr>t<"fg-toolbar ui-widget-header ui-corner-bl ui-corner-br ui-helper-clearfix"ip>'
    });
    });
    and receive in TableTools

    var TableToolsInit = {
    "oFeatures": {
    "bPdf": true,
    "bCsv": true,
    "bXls": true,
    "bCopy": true,
    "bPrint": true
    },
    "sPrintMessage": "",
    "sTitle": "",
    "sUrlPDF":"", /// here ???
    "sSwfPath": "/swf/ZeroClipboard.swf",
    "iButtonHeight": 30,
    "iButtonWidth": 30,
    "_iNextId": 1 /* Internal useage - but needs to be global */
    };

    thats corrects?, becouse doesnt work for me
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Hello,

    It would actually be possible to add PDF output to TableTools by modifying the ZerClipboard.fla file to input the option to output to PDF (this can be done in ActionScript as well as any other language - for example: http://alivepdf.bytearray.org/ ). So what you would do is add a new button to TableTools, and set a new output type in the swf (the current two are save as text file and copy to clip-board), to save as a PDF, and then that's it done.

    It might be a bit complicated to do - but it's certainly possible. The other option is to pass the whole lot to a server-side process and have that render your PDF for you. The problem with including this in TableTools as a package, would be that I would only be able to provide limited customisation of the PDF - so far better that anyone who wants this support can add it - hooray for open source :-)

    Regards,
    Allan
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    @harklick: I'd say it was actually easier to just put your URL in TableTools rather than the DataTables initialiser, unless there is a good reason to put it in there? If there is then you'll need to add it into the settings object and access that in TableTools.

    Allan
  • hardlickhardlick Posts: 14Questions: 0Answers: 0
    thanks for your answers Allan, the url that i want pass should be dinamic, can change,
    is why i want pass the url in the file that put the url here
    olisttable = $('#example').dataTable({
    "iDisplayLength": 10,
    "bAutoWidth":false,
    "bJQueryUI": true,
    "sUrlPDF":"/exportpdffile.php", // this

    so, when i click the pdf button call the url pass in sUrlPDF x example, and the result is a PDF file.
    in this file, is the code for generate pdf por example:
    exportpdffile.php:
    require_once("libraries/dompdf/dompdf_config.inc.php");
    if (isset ($_GET['date']))
    {
    $objReferrals = new Referrals();
    $listRef = $objReferrals->listReferralsByMsoandDate($mso_code, $_GET['date']);

    $html = '
    Prueba 2

    body
    {
    font-size:10px;
    margin-top: 40px;

    margin-bottom: 20px;
    }
    table, th, td {
    border: 1px solid #D4E0EE;
    border-

    ......
    $dompdf = new DOMPDF();
    $dompdf->load_html($html);
    $dompdf->render();
    $dompdf->stream("ReferralsByMsoandDate.pdf");

    how can i do that?, is posible?
  • hardlickhardlick Posts: 14Questions: 0Answers: 0
    edited September 2009
    thanks a lot for everything, i can solved my problem ;), i could put a new button in the box with an image of pdf, and could add an url dynamically for this button.
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Hi hardlick,

    Nice one - good to hear that's sorted.

    Regards,
    Allan
  • ShadokShadok Posts: 19Questions: 0Answers: 0
    Everything's fixed thanks to Allan :)
This discussion has been closed.