5

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?

  1. Is it possible to export individual columns to Excel in jQuery DataTables?
  2. Is it possible to export a column that was previously hidden using the fnSetColumnVis function?

2 Answers 2

9

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks a lot! This helped, especially the link!
4

See the following code block, hope it will help you.

$(document).ready( function () {    
    $('#datagridtable').dataTable( {
        "sDom": '<"H"Tfr>tC<"F"ip>',

        "oColVis": {
            "buttonText": "&nbsp;",
            "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
                }, ]
        }
    } );
} );

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.