We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Remove Columns when exporting to pdf, excel and word

Hi,
 
I want to remove some columns that are visible in the Grid, so that they do not appear in the exported pdf, excel and word. Is this possible?

Also I would like to change the buttons for the exporting functions, atleast the labels.

Thanks

3 Replies

BM Bala Murugan A.S Syncfusion Team August 12, 2013 12:13 PM UTC

Hi Richard Norton,

 

Thanks for using Syncfusion Products.

 

Query 1: Exclude column while export.

 

We suggest you to set Visible property of column while exporting in OnToolbarClickEvent client side event to achieve your requirement. Please refer the below code snippet.

[Index.cshtml]

.ClientSideEvents(e=>e.OnToolbarClickEvent("pdf_export"))

<script type="text/javascript">

    function pdf_export(sender, args) {

      

        if (args._currentItemId == sender._ID + 'pdf_export'

            || args._currentItemId == sender._ID + 'word_export'

            || args._currentItemId == sender._ID + 'excel_export') {

            var _VisibleColumns = new Array();

            $.each(sender.get_VisibleColumns(), function (index, Column) {

                if (Column.Name == "EmployeeID") {

                    Column.Visible = false; //removing columns for export

                }

                if (Column.Visible == true) {

                    _VisibleColumns.push(Column); //visible columns

                }

            });

            sender.set_VisibleColumns(Sys.Serialization.JavaScriptSerializer.serialize(_VisibleColumns)); //Set visible columns.

        }

    }

 

</script>

 

Query 2: Changing Export labels in toolbar

 

We suggest you to give name while adding export toolbar to achieve your requirement. Please refer the below code snippets.

 

[Index.cshtml]

.ToolBar(tools =>

                       {

                           tools.Add(GridToolBarItems.PDFExport, "PDF Export");

                           tools.Add(GridToolBarItems.WordExport, "Word Export");

                           tools.Add(GridToolBarItems.ExcelExport, "Excel Export");

 

                       })

For your convenience we have prepared a simple sample to demonstrate this and the same can be downloaded from the below link.

 

Sample: Export.zip

 

Note: We have given support to 'Excluding columns while export' by using Exportable property of the column and this will be available in our upcoming volume release(11.3) which will be scheduled to be released in last week of august this year. If you need this we will provide patch. Could you please let us know your current version of syncfusion product?

 

Please let us know if you have any queries.

 

Regards,

Bala Murgan A.S



RN Richard Norton August 15, 2013 02:02 AM UTC

Thank you, the solution was perfect!


BM Bala Murugan A.S Syncfusion Team August 19, 2013 05:05 AM UTC

Hi Richard,

Thanks for your update.

We are happy to hear your issue has been resolved. Please get back to us if you need further assistance.

Thanks and Regards,
Bala Murugan A.S

Loader.
Live Chat Icon For mobile
Up arrow icon