How can I exclude the first column from being exported?

How can I exclude the first column from being exported?

Andreas85Andreas85 Posts: 12Questions: 0Answers: 0
edited June 2012 in TableTools
The first column in my tables contain some control buttons (edit, delete, change status). So I don't want to export them.
So can I skip that one somehow?

And also, some of my cells contain commas.
(Matrix M650 SK (2,3) JTD 43 H 130 HP)

So excel interprets that as the beginning of a new cell.
How can I fix that?

Thanks for a great product.

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    You can use the mColumns and fnCellRender options for TableTools buttons to customise the output as you wish: http://datatables.net/extras/tabletools/button_options

    Allan
  • Andreas85Andreas85 Posts: 12Questions: 0Answers: 0
    When I try to run fnCellRender in jsbin I can't even find the button for exporting, and there are three dropdowns for the amount of rows to be displayed.
    I tried putting an alert in the fnCellRender function but it never pops up.

    Am I doing something wrong? Same thing with mColumns.
  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    What code are you using for the two options? There are examples of how they can be used in the documentation.

    Allan
  • Andreas85Andreas85 Posts: 12Questions: 0Answers: 0
    This is what I'm using for fnCellRender. Thought I'd begin with that.

    [code]
    $(document).ready( function () {
    $('#example').dataTable( {
    "sDom": 'T<"clear">lfrtip',
    "oTableTools": {
    "sExtends": "xls",
    "sButtonText": "Hello world",
    "sSwfPath": "<?=base_url()?>verkstad/lib/TableTools/media/swf/copy_csv_xls.swf",
    "fnCellRender": function ( sValue, iColumn ) {
    alert('asdas');
    // Append the text 'TableTools' to column 5
    if ( iColumn === 5 ) {
    return sValue +" TableTools";
    }
    return sValue;
    }
    }

    });
    });
    [/code]

    I don't get any error messages. Exporting to xls works fine, but I don't get the alert
  • Andreas85Andreas85 Posts: 12Questions: 0Answers: 0
    I forgot to put it in "aButtons". Now it works.
  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    Have a look at the examples again - the fnCellRender function is applied to the buttons in the aButtons array - not the top level TableTools configuration object.

    Allan
  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    Message overlap - good to hear you got it working.
  • Andreas85Andreas85 Posts: 12Questions: 0Answers: 0
    Yeah :) Thanks for your help.
This discussion has been closed.