Include a button to the export files

Include a button to the export files

floveraflovera Posts: 12Questions: 0Answers: 0
edited October 2013 in Editor
Hello, I have developed the datatables, and I'm using tabletools to generate xls and csv files. But in my table one of the columns is a button how can I display the data of this button inside the xls or csv files? (When I do the exports, this column appears to be empty, obviously is null).

Thanks

Replies

  • allanallan Posts: 63,531Questions: 1Answers: 10,475 Site admin
    You would need to use the fnCellRender method: http://datatables.net/extras/tabletools/button_options#fnCellRender .

    Allan
  • floveraflovera Posts: 12Questions: 0Answers: 0
    Yes Im trying to use that, I have this:

    "fnCellRender": function ( sValue, iColumn, nTr, iDataIndex ) {
    var valueExport = "";
    var data = $(sValue)[0];

    var tag = data.tagName;

    if(iColumn == 1){

    valueExport = data.getAttribute("value");
    }

    return valueExport;
    }

    But it doesn't work at all =(
  • floveraflovera Posts: 12Questions: 0Answers: 0
    edited October 2013
    Please help. I've spent a day in this problem and I don't know why is wrong
  • floveraflovera Posts: 12Questions: 0Answers: 0
    I solved it!!
    The problem was in my fnCellRender function, this is my code (that works):

    Code:
    "mColumns": [ 0, 1, 2 ],
    "fnCellRender": function ( sValue, iColumn, nTr, iDataIndex ) {

    if(iColumn == 0){
    var data = $(sValue)[0];
    var valueExport = data.getAttribute("value");
    return valueExport;
    }else if(iColumn == 3){
    return 0;
    }
    return sValue;
    }


    Enjoy ;)
  • allanallan Posts: 63,531Questions: 1Answers: 10,475 Site admin
    Good to hear you got it sorted out.

    Allan
This discussion has been closed.