DataTables logo DataTables

via Ad Packs
How can I exclude the first column from being exported?
  • Andreas85Andreas85
    Posts: 12
    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.
  • allanallan
    Posts: 15,551
    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: 12
    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: 15,551
    What code are you using for the two options? There are examples of how they can be used in the documentation.

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

    $(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;
    	                 }
    		}
    					
    	});
    });
    

    I don't get any error messages. Exporting to xls works fine, but I don't get the alert
  • Andreas85Andreas85
    Posts: 12
    I forgot to put it in "aButtons". Now it works.
  • allanallan
    Posts: 15,551
    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: 15,551
    Message overlap - good to hear you got it working.
  • Andreas85Andreas85
    Posts: 12
    Yeah :) Thanks for your help.
This discussion has been closed.
← All Discussions

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Support

Get useful and friendly help straight from the source.

In this Discussion