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.
Unfortunately, activation email could not send to your email. Please try again.

Remove Columns when exporting to pdf, excel and word

Thread ID:

Created:

Updated:

Platform:

Replies:

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

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 08:13 AM

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 14, 2013 10:02 PM

Thank you, the solution was perfect!

Bala Murugan A.S [Syncfusion]
Replied On August 19, 2013 01:05 AM

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.

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.

;