Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Datatables export buttons #771

Open
AshRaghav opened this issue Nov 2, 2016 · 4 comments
Open

Datatables export buttons #771

AshRaghav opened this issue Nov 2, 2016 · 4 comments

Comments

@AshRaghav
Copy link

Hi @ebrehault ,

I am trying to enable the "TableTools" option for all datatables in our site. Have registered the necessary javascript and css under portal_javascripts and portal_css registries.

"sDom": 'T<"clear">lfrtip',
"oTableTools": {
"sSwfPath": "../swf/copy_csv_xls_pdf.swf"
}

Used the above code inside Dynamic table parameters in one of the views we have and it doesn't seem to show any buttons for export except that some CSS got distorted.

I also tried the aButtons script to no avail.

"aButtons": [
"copy",
"print",
{
"sExtends": "collection",
"sButtonText": "Save",
"aButtons": [ "csv", "xls", "pdf" ]
}
]

Obviously doing something wrong here. Can you kindly throw some light please?

Thanks

@ebrehault
Copy link
Member

Difficult to tell.
Do you get any javascript error in your browser?

@AshRaghav
Copy link
Author

Thanks Eric. You are right. There appears to be a JavaScript error, however no clue what it is relating to.

tabletools-javascript-error

The JavaScript lines where the error is reported at points to the below snippet

var oClasses=oSettings.oClasses;var an=oSettings.aanFeatures.p;var nNode;for(var i=0,iLen=an.length ;i<iLen ;i++){nNode=an[i].firstChild;if(nNode){nNode.className=(oSettings._iDisplayStart===0)?oClasses.sPagePrevDisabled:oClasses.sPagePrevEnabled;nNode=nNode.nextSibling;nNode.className=(oSettings.fnDisplayEnd()==oSettings.fnRecordsDisplay())?oClasses.sPageNextDisabled:oClasses.sPageNextEnabled}}}},"iFullNumbersShowPages":5,"full_numbers":{"fnInit": function(oSettings,nPaging,fnCallbackDraw){var oLang=oSettings.oLanguage.oPaginate;var oClasses=oSettings.oClasses;var fnClickHandler=function(e){if(oSettings.oApi._fnPageChange(oSettings,e.data.action)){fnCallbackDraw(oSettings)}};$(nPaging).append('<a tabindex="'+oSettings.iTabIndex+'" class="'+oClasses.sPageButton+" "+oClasses.sPageFirst+'">'+oLang.sFirst+''+'<a tabindex="'+oSettings.iTabIndex+'" class="'+oClasses.sPageButton+" "+oClasses.sPagePrevious+'">'+oLang.sPrevious+''+''+'<a tabindex="'+oSettings.iTabIndex+'" class="'+oClasses.sPageButton+" "+oClasses.sPageNext+'">'+oLang.sNext+''+'<a tabindex="'+oSettings.iTabIndex+'" class="'+oClasses.sPageButton+" "+oClasses.sPageLast+'">'+oLang.sLast+'');var els=$('a',nPaging);var nFirst=els[0],nPrev=els[1],nNext=els[2],nLast=els[3];oSettings.oApi._fnBindAction(nFirst,{action:"first"},fnClickHandler);oSettings.oApi._fnBindAction(nPrev,{action:"previous"},fnClickHandler);oSettings.oApi._fnBindAction(nNext,{action:"next"},fnClickHandler);oSettings.oApi._fnBindAction(nLast,{action:"last"},fnClickHandler);if(!oSettings.aanFeatures.p){nPaging.id=oSettings.sTableId+'_paginate';nFirst.id=oSettings.sTableId+'_first';nPrev.id=oSettings.sTableId+'_previous';nNext.id=oSettings.sTableId+'_next';nLast.id=oSettings.sTableId+'_last'}},"fnUpdate": function(oSettings,fnCallbackDraw){if(!oSettings.aanFeatures.p){return}

Although it is always possible that there could be some other problem. Have you got any working examples of this implementation that I can refer to?

Thanks

@ebrehault
Copy link
Member

It seems your JS is corrupted, you probably made a bad copy/paste or something, but it ends up with a syntax error somewhere.

@AshRaghav
Copy link
Author

Thanks Eric - it ended up being a silly issue with Javascript registry. After I triple checked everything the buttons started working. One thing that did tumble me out was including the SWF file for the buttons. Eventually used the same method as ZCML config file for declaring resources to be included.

Its an extremely useful tool to have in terms of the controlling the search columns and exporting data. Have used plomino's /exportXLS and it hasn't worked very well for us.

I would wish we have some example for those who may benefit from it. I am more than happy to do a small tutorial for your review if you would like to consider.

Secondly, Datatables have deprecated the use of TableTools with buttons - possibly switching from Flash to HTML5. I am hoping that someone is already working on the collective datatables JS for adopting the newer version.

Thanks again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants