TableTools - Button Collections bug ¿?¿?

TableTools - Button Collections bug ¿?¿?

equisdeequisde Posts: 34Questions: 0Answers: 0
edited July 2012 in Bug reports
Hello,

I´m using DataTables TableTools plug-in in order to have the choice to export the info to an external file.
I was implementing it with Buttons Collection feature in this link

http://datatables.net/release-datatables/extras/TableTools/collection.html

This way i will have Export options into a single button labeled as "Save as.."

Doh! Excel button in the dropdown list once you pressed Save button does not work in this website example (checked with several browsers)

:(

Replies

  • equisdeequisde Posts: 34Questions: 0Answers: 0
    Nobody has the same problem?
  • equisdeequisde Posts: 34Questions: 0Answers: 0
    allan are you there? :D
  • allanallan Posts: 63,687Questions: 1Answers: 10,500 Site admin
    Yes that looks like a bug I'm afraid. I'll look into it for the next TableTools release.

    Thanks from bringing it to my attention.

    Allan
  • equisdeequisde Posts: 34Questions: 0Answers: 0
    Ok allan. I will be waiting patiently for the next release :)

    Cheers!
  • allanallan Posts: 63,687Questions: 1Answers: 10,500 Site admin
    I've just committed the required fix for this ( https://github.com/DataTables/TableTools/commit/f01bb08e925642a3391ff250bdfe8bd28efc65ea ) and it will be in TableTools 2.1.3 which I will release soon.

    It would be great if yourself or anyone else can download the git repo and check that collections now do work for you before I make the release - just in case!

    Allan
  • yamichaudyamichaud Posts: 4Questions: 0Answers: 0
    Hello,
    I'm using quite the same patch since a few days a it seems to work perfectly. I've just applied yours and let you know if I can see any difference.

    Nevertheless, I'm facing another problem with the collection button.
    If I put custom buttons as a collection, the fnClick function is never called.

    Here is the code I use :

    TableTools.BUTTONS.likemode = $.extend( {}, TableTools.buttonBase, {
    "sAction":"div",
    "sTag":"default",
    "sToolTip":"Use Like mode",
    "sButtonClass":"DTTT_button_regexplike DTTT_button_regexplike_selected",
    "sButtonClassHover":"DTTT_button_regexplike_hover",
    "sButtonText":"Like",
    "fnClick": function(nButton,oConfig){
    console.log(nButton);
    }
    } );

    TableTools.BUTTONS.regexpmode = $.extend( {}, TableTools.buttonBase, {
    "sAction":"div",
    "sTag":"default",
    "sToolTip":"Use Regexp mode",
    "sButtonClass":"DTTT_button_regexplike",
    "sButtonClassHover":"DTTT_button_regexplike_hover",
    "sButtonText":"Regexp",
    "fnClick": function(nButton,oConfig){console.log(nButton);}
    }
    );


    var icapTableToolsFormat = {
    "sSwfPath":"library/DataTables-1.9.2/extras/TableTools/media/swf/copy_csv_xls_pdf.swf",
    "aButtons": [
    {"sExtends":"copy","sButtonText":"","mColumns":"visible","sToolTip":"Copy to clipboard","bFooter":false},
    {"sExtends":"csv","sButtonText":"","mColumns":"visible","sToolTip":"Save as CSV","bFooter":false,"sFileName":"DMan2.csv"},
    {"sExtends":"xls","sButtonText":"","mColumns":"visible","sToolTip":"Save as Excel file","bFooter":false,"sFileName":"DMan2.xls"},
    {"sExtends":"pdf","sButtonText":"","mColumns":"visible","sToolTip":"Save as PDF","sPdfOrientation":"landscape","bFooter":false,"sFileName":"DMan2.pdf"},
    {"sExtends":"collection","sButtonText":"Mode",
    "aButtons":[
    {"sExtends":"likemode"},{"sExtends":"regexpmode"}
    ]
    }
    ]
    };

    I've added some trace in TableTools.js :
    - fnCreateButton is called.
    - fnTextConfig is also called but, with the following code, I get 1 and 3 for both the collection button (Mode is my example) and my two custom buttons but I only get 2 when I click on the 'Mode' button.

    console.log('1');
    $(nButton).mousedown( function (e) {
    //e.preventDefault();
    console.log('2');
    if ( oConfig.fnClick !== null )
    {
    oConfig.fnClick.call( that, nButton, oConfig, null );
    }

    /* Provide a complete function to match the behaviour of the flash elements */
    if ( oConfig.fnComplete !== null )
    {
    oConfig.fnComplete.call( that, nButton, oConfig, null, null );
    }

    that._fnCollectionHide( nButton, oConfig );
    } );
    console.log('3');

    This problem is also happening on "hover" event.

    I've been working on it for 3 days and I can't see any problem. Do you have an idea where it might come from ?

    Thanks for your help

    Yoann
  • equisdeequisde Posts: 34Questions: 0Answers: 0
    edited July 2012
    Hello allan,

    After tried the fix that you posted on GitHub seems that everything is working fine ( only tested in Chrome)

    Thanks for your great job
  • allanallan Posts: 63,687Questions: 1Answers: 10,500 Site admin
    @equisde - excellent - thanks very much for the feedback.

    Allan
  • yamichaudyamichaud Posts: 4Questions: 0Answers: 0
    Hello Allan,

    It looks like there is still a problem regarding the offset when you use collection buttons.
    I tried to use the buttons under "save" in your example page : http://datatables.net/release-datatables/extras/TableTools/collection.html and it doesn't seem to work correctly.
    The problem I mentioned earlier is maybe linked to this problem.

    In addition, if you use a print button in a collection (so no flash used), the fnClick doesn't seem to be triggered.

    Could you confirm this behavior so I can consider it's not a local configuration problem.

    Thanks for your amazing job.

    Yoann
  • allanallan Posts: 63,687Questions: 1Answers: 10,500 Site admin
    My update has not been released and deployed onto this server yet - so the example you linked to is still using the old broken code. If you could update to the very latest code from git, and try again that would be great.

    Allan
  • yamichaudyamichaud Posts: 4Questions: 0Answers: 0
    I've upgraded to the very last version of tabletools and the offset is correct.
    But there is no way to make the print button work in a buttons collection.
    From my understanding/testing, only the buttons which require flash are working in a collection mode.

    Yoann
  • allanallan Posts: 63,687Questions: 1Answers: 10,500 Site admin
    > But there is no way to make the print button work in a buttons collection.

    Can you link me to an example of that problem please?

    Allan
  • yamichaudyamichaud Posts: 4Questions: 0Answers: 0
    Hello Allan,

    I've finally found out the origin of the problem.

    In the previous TableTool version, the DTTT_Collection was created when the collection button was first clicked.
    In the last version, the DTTT_collection is created when the DataTable is build and set to [code]display:none[/code]

    Because I load every page with JQuery, the DTTT_collection element is created each time I display a new datatable but the old ones are never destroyed.
    That's why I was using [code]$('.DTTT_collection').remove();[/code]
    To be sure that this function would be always called, I put it in the fnFilterOnReturn() function which is called after the Datatable creation.

    As a consequence, I would have expected the DTTT_collection to be not working at all but strangely, everything is working except the buttons which do not require flash.

    I've now put the [code]$('.DTTT_collection').remove();[/code] before the Datatable creation and it works perfectly.

    Thanks for your help

    Yoann
  • savasava Posts: 4Questions: 0Answers: 0
    Hi Allan,

    For what its worth, I ran into the same issue today.

    I updated the TableTools.css, ZeroClipboard.js and TableTools.js as per the github link and the collections buttons I have seem to be working fine now.

    Worth noting they now present in a vertical list as apposed to the horizontal one of the previous version and the demo which is fine by me.

    Tested this in IE9 and FF14, also under IE8 and it seems fine.


    Cheers.
  • allanallan Posts: 63,687Questions: 1Answers: 10,500 Site admin
    > updated the TableTools.css, ZeroClipboard.js and TableTools.js as per the github link and the collections buttons I have seem to be working fine now.

    Excellent - thanks for letting me know. I think TableTools 2.1.3 will be released next week.

    > Worth noting they now present in a vertical list as apposed to the horizontal one of the previous version and the demo which is fine by me.

    That's interesting, I think I committed a fix for that just a few days ago. I'll double check that its gone in before packaging it up :-)

    Allan
This discussion has been closed.