Arasu
Arasu

Reputation: 2148

hide columns while generating excel using TableTools in jQuery Datatable - Datatables.net

In Datatables while viewing in the browser we show n columns. When a user clicks generate excel (implemented using TableTools), I want to hide some unneeded columns.

How to hide columns at runtime?

Upvotes: 2

Views: 4826

Answers (2)

Hope this will help

$(document).ready( function () {
$('#example').dataTable( {
    "sDom": 'T<"clear">lfrtip',
    "oTableTools": {
        "aButtons": [
            {
                "sExtends": "csv",
                "sButtonText": "Special columns",
                "mColumns": [ 0, 1, 4 ]
            },
            {
                "sExtends": "csv",
                "sButtonText": "Visible columns",
                "mColumns": "visible"
            }
        ]
    }
} );
} ); 

check this link http://datatables.net/extras/tabletools/button_options#collection_options

Upvotes: 4

jlrolin
jlrolin

Reputation: 1614

Check out Allan's release of Table Tools 2. I believe it has a mColumns property that allows you to specify what columns will be visible on the export when it is clicked.

Upvotes: 1

Related Questions