aButtons export csv content

aButtons export csv content

yiurenmayiurenma Posts: 7Questions: 4Answers: 0

In my table , there is a column value is "google" and when user click it , it will be a link to google website. But when user want to export the csv content , I want to change the google value as a link instead . For now , the csv content is just google text. How to do it in my aButtons feature ? below is my code :
"oTableTools": {
"sSwfPath": "http://cdn.datatables.net/tabletools/2.2.2/swf/copy_csv_xls_pdf.swf",
"aButtons": [
{
"sExtends": "csv",
"sButtonText": "export csv",
}
]
}

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,121Questions: 1Answers: 10,397 Site admin
    Answer ✓

    Firstly I would suggest you ditch the legacy TableTools plug-in, it is no longer supported.

    To do what you want with Buttons (TableTools' replacement) there are two options - see these examples:

    Allan

  • yiurenmayiurenma Posts: 7Questions: 4Answers: 0

    Hi Allan

    Thanks for your response. But it is not easy to replace the old version as my company use this version and once it change , a lot of code change should be changed . And I have found below fnCellRender help me for this problem . Hope it can help others who have the same problem.


    "oTableTools": { "https://cdn.datatables.net/tabletools/2.2.2/swf/copy_csv_xls_pdf.swf", "aButtons": [ { "sExtends": "csv", "sButtonText": "download CSV", "sCharSet": "utf8", "bBomInc": true, "fnCellRender": function ( sValue, iColumn, nTr, iDataIndex ) { if(sValue.toString().match("href")){ return $(sValue).attr("href"); } return sValue; } } ] },

    ```

This discussion has been closed.