TableTools 2 released!

TableTools 2 released!

allanallan Posts: 63,643Questions: 1Answers: 10,492 Site admin
edited January 2011 in Announcements
Hello all,

I'm absolutely delighted to be able to release TableTools 2! It's been quite a while in coming, but the code is now complete, the documentation is online and the download is primed and ready for you to hit!

Check out the examples:
http://datatables.net/release-datatables/extras/TableTools/

And download the source (stick it in the DataTables "extras" directory):
http://datatables.net/releases/TableTools-2.0.0.zip

Documentation:
http://datatables.net/extras/tabletools/

Some details:
TableTools 2 is a complete rewrite of the original v1 software providing _much_ greater flexibility of the buttons TableTools can set up and including a couple of great new features. The first of those features is user row selection - when initialising TableTools you can now select a 'single' or 'multi' (the default is 'none') row selection, allowing easy interaction with the table. The other major new feature is PDF export. While the visual appearance of the file is quite basic, it can be modified as you need using the TableTools source.

Despise these new features, the real "meat" in TableTools 2 is it's super configurable buttons. TableTools 2 is now a real toolbar for DataTables which can be extended to provide custom buttons beyond the default ones so easily now. There are also a lot of built-in button types which can be readily extended to do exactly what you want.

Possibly the best part of this release is that TableTools now has detailed documentation ( http://datatables.net/extras/tabletools/ )! Actually, with this release all first-class plug-ins for DataTables enjoy the same level of documentation as DataTables itself! :-)

If you happen find any issues with TableTools 2, please open a new thread with the details there (so we don't have overlapping conversations here).

Finally, if you are finding DataTables / TableTools or any of the other software on this site useful, please make a donation. These donations allow me to continue developing DataTables, TableTools and everything else here:
http://datatables.net/donate

Enjoy!
Allan

Replies

  • sevenelevenseveneleven Posts: 6Questions: 0Answers: 0
    Really nice, love the plugin. I just noticed that export to xls is using a .csv extension. Any ideas?

    Thank you
  • allanallan Posts: 63,643Questions: 1Answers: 10,492 Site admin
    Hi seveneleven,

    Yes you are quite right. The XLS export isn't really an XLS file, but really an "Excel export" with a UTF16-LE CSV file, which Excel will read ( http://datatables.net/extras/tabletools/buttons#xls ). The reason for doing it this way is that if you save a CSV file with a .xls extension, the newer versions of Excel will give a warning - which people have highlighted in the forum before, their client's don't really like! This is effectively a work around for that - you can use the 'sFileName' option to set it to .xls if you wish.

    At some point I hope to write a true XLS exporter for TableTools, but it's not exactly trivial to do, and will probably require a fair bit of development. But something that should come at some point!

    Regards,
    Allan
  • bryceray1121bryceray1121 Posts: 65Questions: 0Answers: 0
    Is it possible to use the printing functionality without swf/flash?

    I've already created custom printing functionality for my tables, however yours seems to work a little more smoothly. Is it possible to directly access the print function off a datatable object? I already have the button integrated into my tables and it would be great if all I had to do was include the js for the new plugin and adjust the onclick on my button to point to the new print function.

    Thanks.
  • allanallan Posts: 63,643Questions: 1Answers: 10,492 Site admin
    Yes indeed it is possible - you need to just customise the buttons that TableTools will display. This example shows just copy and print buttons - you can drop the copy if you want: http://datatables.net/release-datatables/extras/TableTools/alter_buttons.html .

    To activate the print display, it is possible to make use of the TableTools internals. _fnPrintStart is the function you need - it's a private function at the moment (in the sense that Javascript allows...), so you might need to poke around the code a little bit, but it's certainly possible. Another option would be to hide the TableTools print button and then activate the click function attached to it when you need (possibly an easier option).

    I have actually ripped out the print stuff in TableTools to create a small library called Print.js which perhaps does what you are looking for. It's not publicly released yet, but feel free to drop me a mail if you want to have a look at it.

    Allan
  • AldriAldri Posts: 2Questions: 0Answers: 0
    Hey glad to see the release of tabletools 2, i've been using your beta version for a while now and it was already very nice, the release should be even better !
    I assume that you didn't really had the time to take a look at the "full table export" script I sent you (if you need to export a server side datatable with all rows, even unloaded ones)
    I'll take a look at updating it for the release and maybe post it here if you guys are interested :)
  • allanallan Posts: 63,643Questions: 1Answers: 10,492 Site admin
    Hi Aldri,

    I'm afraid I got to the point when I starting thinking how ridiculous it was that it was taking me so long to make the release, so I just wrote up the documentation from where I was and that was the release. So, sorry to say that there isn't a section on the site for server-side scripts yet, but there will be at some point, and I'll be sure to include your script :-)

    Allan
  • hugosolarhugosolar Posts: 2Questions: 0Answers: 0
    Hi everyone
    This is a great plugin for datatables! but i have a problem
    does anyone have troubles with ie 7/8 ?
    the buttons doesn't work and when press the "copy" button tells me 0 rows copied.
    is this a bug? or it can be fixed?
  • hugosolarhugosolar Posts: 2Questions: 0Answers: 0
    nevermind
    i updated datatables 1.7.4 to 1.7.5 and works all right!

    thanks anyway
  • tleuratleura Posts: 1Questions: 0Answers: 0
    Hi,
    Thank you very much for this tool, I just know it for few days ago and it's a very good job.
    I am also interessted in the "full table export", just let me know when you get a time to upgrate it.

    Thanks again.
  • whiterabbitwhiterabbit Posts: 5Questions: 0Answers: 0
    edited February 2011
    Hi,
    this tabletools is great!

    i have a question about the excel export: the filename can be set in the javascript and this filename then appears in the flash file save dialogue. however if the user changes the filename in the dialogue but doesnt put the .xls at the end then it will be saved with no extension. since the typical end user doesnt know about file extensions is there a way that the extension can automatically be added to the end of the filename after it has been changed in the dialogue. would this be a change to the flash?

    thanks
  • akreiderakreider Posts: 33Questions: 0Answers: 0
    Is ZeroClipboard.swf still in use? I didn't see it included in the release. I downloaded the 2.0.0 zip file.

    Instead in the swf directory we have the copy_cvs_xls and copy_cvs_xls_pdf files. But in ZeroClipboard.js (1.0.4 mod) we still have a moviePath of ZeroClipboard.swf.

    I'm going to try using the old ZeroClipboard.swf that I have from a previous release. (This plugin stopped working on me, but that was before I upgraded. So I'm working on fixing the bug and upgrading).

    Thanks for all your work!
  • dittoditto Posts: 6Questions: 0Answers: 0
    I like the new functionality of 2.0 but prefer the look from the 1.0 version much better (it matches MyToolbar)... Is there some way to easily use that with 2.0?
  • allanallan Posts: 63,643Questions: 1Answers: 10,492 Site admin
    @ditto: It comes down to CSS - the new TableTools 2 is a lot easier to style than the original, and it is quite possible to make it look and feel like the original - but I haven't got any example CSS for how to do that I'm afraid.

    @akreider: No ZeroClipboard.swf is not used any more - the two SWF files used are copy_cvs_xls.swf and copy_cvs_xls_pdf.swf (they are more or less the same - expect one includes the PDF library, which increases the file size significantly). There is reference to ZeroClipboard.swf in ZeroClipboard.js for 2.0.0, which I have just removed since it's not needed and just causing a bit of confusion. The only ZerClipboard.swf will not work full with TableTools 2 - it doesn't provide all of the interfaces required.

    @whiterabbit: See this post in reply to this question in a different thread: http://datatables.net/forums/comments.php?DiscussionID=4088&page=1#Item_2

    Regards,
    Allan
  • sammydcsammydc Posts: 2Questions: 0Answers: 0
    @Aldri: How to do a "full table export" server side? Could you post a snippet here? Thanks.
    @allan: Is there a beta of a new TableTools that has "full table export" server side? Many thanks.
  • allanallan Posts: 63,643Questions: 1Answers: 10,492 Site admin
    There isn't - but it's only really a change needed to the server-side, rather than TableTools on the client-side. What you need to do is use the 'ajax' button option to send a request to the server - that request should then generate the XLS or whatever is needed and download that for the end user. I hope to have a gallery of such scripts in future, but I'm afraid I've not had the time to do that yet.

    Allan
  • hareshvidjahareshvidja Posts: 2Questions: 0Answers: 0
    I am very appreciate you using Data table grid view with Table tools v 2.0 functionality.
    But my problem is I can't add Title for the data or summary content about data in PDF. Can I handle it by table tools Options? or how to customize code for achieving this requirement?
  • allanallan Posts: 63,643Questions: 1Answers: 10,492 Site admin
    Hi hareshvidja,

    I've just being doing some work on TableTools and the PDF export this morning and added the ability to include title text and summery information in the PDF using a couple of new configuration options :-). The changes haven't been released yet - there are a couple of other little things I'd like to address in TableTools before doing that, but you can get the very latest code from Github ( https://github.com/DataTables/TableTools ) - just download the zip and extract it to the 'extras' directory in the DataTables distribution.

    The new options are:

    "sPdfOrientation" which can be 'portrait' or 'landscape' to alter the orientation of the output PDF
    "sPdfSize" which can be 'A[3-4]', 'letter', 'legal' or 'tabloid'
    "sPdfMessage" which is a free text input that will show at the top of the table.

    Also the title of the document is controlled by the "sTitle" parameter, which will read the document title, or can be overridden if needed.

    This will be released and fully documented soon.

    Regards,
    Allan
  • bioPorcobioPorco Posts: 14Questions: 0Answers: 0
    Hi allan,
    I'va a problem with PDF export,
    if I set the new options (sPdfOrientation, sPdfMessage, sTitle ) before invoke $('#example').dataTable(dataTableOpt); everything works fine, but i want to ask to user wich title, description and orientation they want every time the users click pdf button (i.e. through prompt function).

    To solve this problem i thought to use the "fnClick" callback of pdf button, but i don't know how to use Zeroclipboard instance.

    After asking the parameters to user how can i pass them to Zeroclipboard instance?
    I want to know how to continue normal execution after executing the code of fnClick function.

    I hope this is a very simple problem.
    Thanks,
    Francesco.

    P.S: when I'll finish the development I'll post a link to page that uses dataTables in "How are you using DataTables?" topic
  • allanallan Posts: 63,643Questions: 1Answers: 10,492 Site admin
    If you have a look at the fnClick function in the TableTools code, you'll be able to see where the parameters are passed in there:

    [code]
    "fnClick": function( nButton, oConfig, flash ) {
    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)
    );
    }
    [/code]
    So for orientation, just put in either "portrait" or "landscape" etc.

    Allan
  • bioPorcobioPorco Posts: 14Questions: 0Answers: 0
    edited March 2011
    Sorry Allan,
    this is my code:
    [code]
    //creating dataTableOpt Object
    //setting dataTableOpt.aaData Array
    //setting dataTableOpt.aoColumns Array
    //setting dataTableOpt.sDom String
    .
    .
    .
    //creating dataTableOpt.oTableTools Object
    //configuring swfPath
    //creating dataTableOpt.oTableTools.aButtons Array
    var pdfOpt=new Object();
    pdfOpt.sExtends="pdf";
    pdfOpt.mColumns="visible";
    pdfOpt.fnClick = function (nButton, oConfig, oFlash) {
    oConfig.sTitle = prompt('Title:');
    oConfig.sPdfMessage = prompt('Description:');
    confirm('Ok');
    if (confirm('Horizontal page?');) {
    oConfig.sPdfOrientation = 'landscape';
    } else {
    oConfig.sPdfOrientation = 'portrait';
    }
    this.fnSetText(oFlash, "title:" + oConfig.sTitle + "\n" +
    "message:" + oConfig.sPdfMessage + "\n" +
    "colWidth:" + this.fnCalcColRatios(oConfig) + "\n" +
    "orientation:" + oConfig.sPdfOrientation + "\n" +
    "size:" + oConfig.sPdfSize + "\n" +
    "--/TableToolsOpts--\n" +
    this.fnGetTableData(oConfig)
    );
    }
    dataTableOpt.oTableTools.aButtons.push(pdfOpt);
    .
    .
    .
    $('#example').dataTable(dataTableOpt);
    [/code]

    After I have inserted title, description and orientation nothing happen.
    How can I open the dialog box that permit to save the pdf file on local file system?

    Obviously if I comment lines from 14 to 30, I can't set title, description and orientation dinamically but everything works fine

    Thanks,
    Francesco.
  • allanallan Posts: 63,643Questions: 1Answers: 10,492 Site admin
    This looks dodgy to me:

    [code]
    if (confirm('Horizontal page?');) {
    [/code]
    Do you not get a Javascript error for the semi-colon? It might be useful to put in a console.log( oConfig.sPdfOrientation ) just after the confirm block and see if it is set to something sensible as well.

    Allan
  • bioPorcobioPorco Posts: 14Questions: 0Answers: 0
    edited March 2011
    Sorry,
    I messed up copying the code, this is the correct code of fnClick function:

    [code]
    oConfig.sTitle = prompt('Title:');
    oConfig.sPdfMessage = prompt('Description: ');
    if (confirm('Horizontal page?')) {
    oConfig.sPdfOrientation = 'landscape';
    } else {
    oConfig.sPdfOrientation = 'portrait';
    }
    console.log('Title: ' + oConfig.sTitle +
    ' message: ' + oConfig.sPdfMessage +
    ' orientaiton: ' + oConfig.sPdfOrientation);
    this.fnSetText(oFlash,
    "title:" + oConfig.sTitle + "\n" +
    "message:" + oConfig.sPdfMessage + "\n" +
    "colWidth:" + this.fnCalcColRatios(oConfig) + "\n" +
    "orientation:" + oConfig.sPdfOrientation + "\n" +
    "size:" + oConfig.sPdfSize + "\n" +
    "--/TableToolsOpts--\n" +
    this.fnGetTableData(oConfig));
    console.log('Bump!');
    [/code]

    and this is the log:
    [code]
    Title: Document Title message: descripton... orientaiton: landscape
    Bump!
    [/code]

    Unfortunately I don't know English very well, and perhaps before I have not explained well:
    In the output of console there is no warning or error, but only the previus log and so the function executes to the end, but doesn't open the window to save the pdf file.


    I hope not to waste your time with these questions, but would be very helpful for me to solve this problem.
    Thank you very much,
    Francesco.
  • allanallan Posts: 63,643Questions: 1Answers: 10,492 Site admin
    edited March 2011
    Your English is excellent - no worries there :-). It's just taking me a little bit of time to get to the root cause as I'm not sure what is causing the problem. Can you give me a link to your page ( http://datatables.net/contact if you don't want to make it public)? I don't see anything obviously wrong I'm afraid. And if you don't use your own fnClick - it works fine? I'm a bit stuck at the moment...

    Allan
  • bioPorcobioPorco Posts: 14Questions: 0Answers: 0
    Hi Allan,
    I make extensive use of google translator to write in english :-)

    Since i'm developing a google gadget, I've sent to you a link to a google sites page, if you have some trouble to access it, please tell me.

    endless thanks for your help and availability.
    Francesco.
  • allanallan Posts: 63,643Questions: 1Answers: 10,492 Site admin
    Hi Francesco,

    Thanks very much for the link. I've just tried the PDF button on the page you gave me and it seems to work absolutely fine - I get a nice PDF saved to my Desktop with the title of '123' in it (although I did notice that the title wasn't used for the file name - that's the http://datatables.net/extras/tabletools/button_options#sFileName option).

    Are you using the Flash 10 plug-in on your computer? I guess so if it works without your custom fnClick... Hmmm - I'm a bit stuck! If you try a different web-browser does it work? Or clear your cache?

    Allan
  • bioPorcobioPorco Posts: 14Questions: 0Answers: 0
    Allan, It's a mistery!
    I use chrome 10.0.648.133 with Flash (Version: 10.2.154.18 Shockwave Flash 10.2 r154) or firefox 3.6.14 with flash (10.2.152.32) but neither with firefox nor with chrome doesn't work, even i cleared the cache.

    Anyway, i have understood that it's my problem with my computer and so I will not stress yourself anymore.

    Thanks a lot.

    Francesco.
  • lightswitch05lightswitch05 Posts: 2Questions: 0Answers: 0
    edited March 2011
    I was having this same problem. I cleared Chrome cache, restarted the server, and it started working in all browers

    Hope this helps,
    Daniel
This discussion has been closed.