On a web page I am displaying a list of topics created by the website users with only their titles listed. I can export to excel the whole table using TableTools and it works fine. However, some of the columns are not required, and I would like to hide some of them somehow. In a perfect situation I would like to display a small popup window when a user clicks the "XLS" button, with several checkboxes with respective table headers and a button "Export". This way the user can select only the necessary data for export. Can someone direct me, please?
See the following code block, hope it will help you.
$(document).ready( function () {    
    $('#datagridtable').dataTable( {
        "sDom": '<"H"Tfr>tC<"F"ip>',
        "oColVis": {
            "buttonText": " ",
            "bRestore": true,
            "sAlign": "right"
        },
        "oTableTools": {
            "sSwfPath": "datagrid/media/swf/copy_csv_xls_pdf.swf",
            "aButtons": [ 
                {'sExtends':'xls',
                    'mColumns':'visible' //set which columns here
                }, 
                {'sExtends':'pdf',
                    'mColumns':'visible' //set which columns here
                },
                {'sExtends':'print',
                    'mColumns':'visible' //set which columns here
                }, ]
        }
    } );
} );
                        When you define your buttons in oTableTools, you can set which columns to export:
"oTableTools":{
    'aButtons':[
        {'sExtends':'xls',
         'mColumns':[1,2,7,23] //set which columns here
        },
        {'sExtends':'pdf',
         'mColumns':'visible' //set which columns here
        },
                                ]
}
The docs are here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With