- Home
- Forum
- ASP.NET MVC (Classic)
- Remove Columns when exporting to pdf, excel and word
Remove Columns when exporting to pdf, excel and word
Also I would like to change the buttons for the exporting functions, atleast the labels.
Thanks
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
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
- 3 Replies
- 2 Participants
-
RN Richard Norton
- Aug 12, 2013 12:58 AM UTC
- Aug 19, 2013 05:05 AM UTC