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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Remove Columns when exporting to pdf, excel and word

Thread ID:

Created:

Updated:

Platform:

Replies:

110543 Aug 12,2013 12:58 AM UTC Aug 19,2013 05:05 AM UTC ASP.NET MVC (Classic) 3
loading
Tags: Grid
Richard Norton
Asked On August 12, 2013 12:58 AM UTC

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

Bala Murugan A.S [Syncfusion]
Replied On 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


Richard Norton
Replied On August 15, 2013 02:02 AM UTC

Thank you, the solution was perfect!

Bala Murugan A.S [Syncfusion]
Replied On 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

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;