How to exclude a template or column from the Blazor DataGrid while exporting?

Answer:

The template column can be exclude by using any one of the below two solutions.

If the IncludeTemplateColumn property of PdfExportProperties/ExcelExportProperties is set to false then the template columns will not be exported. Here is the code snippet for your reference,


public void ToolbarClick(Syncfusion.Blazor.Navigations.ClickEventArgs args)

{

if (args.Item.Id == "Grid_pdfexport")

{

PdfExportProperties ExportProperties = new PdfExportProperties();

ExportProperties.IncludeTemplateColumn = false;

this.Grid.PdfExport(ExportProperties);

}

}


To export the required columns define the Columns property of PdfExportProperties/ExcelExportProperties. Here is the code snippet for your reference,


public void ToolbarClick(Syncfusion.Blazor.Navigations.ClickEventArgs args)

{

if (args.Item.Id == "Grid_pdfexport")

{

PdfExportProperties ExportProperties = new PdfExportProperties();

ExportProperties.Columns = new List()

{

new GridColumn(){ Field= "EmployeeID", HeaderText="Employee ID", TextAlign=TextAlign.Right, Width="120" }

};

this.Grid.PdfExport(ExportProperties);

}

}

Find the sample to exclude an template or column while exporting here.



Loader.
Up arrow icon