This is a migrated thread and some comments may be shown as answers.

Problem using "GridExporting" to format output.

1 Answer 118 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ken Lassesen
Top achievements
Rank 2
Ken Lassesen asked on 16 Jun 2010, 12:19 AM
I'm trying to customize the output format of a grid. Code that logically should work, seems to have no effect...

 

// Add event handler   
grid.GridExporting += new OnGridExportingEventHandler(grid_GridExporting);   
 
which points to:

 

 

// The handler: showing only the PDF branch   
static void grid_GridExporting(object source, GridExportingArgs e)   
 {  
RadGrid grid = (RadGrid)source;   
switch (e.ExportType)   
 {  
    case ExportType.Pdf:   
      ApplyStylesToPDFExport(grid.MasterTableView);  
      break;   
 }  
}  
 
 
 

Which calls:

 

 

 


 

// The routine, trimmed to simple example...  the code executes when I step thru it...  
static void ApplyStylesToPDFExport(GridTableView gtable)   
{  
foreach (GridColumn col in gtable.Columns)   
{  
col.HeaderStyle.BackColor = System.Drawing.Color.Silver;   
col.HeaderStyle.ForeColor = System.Drawing.Color.Red;   
}   
}  
 
 

 

 

 

So what am I doing wrong OR how can I do the equivalent.  The PDF export is done by the built-in export buttons...   All of the code is in a Utility class because it will be used on dozens of pages...

 

 

1 Answer, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 18 Jun 2010, 08:41 PM
Hello Ken,

I'm afraid it is too late to apply these styles on GridExporting when exporting to PDF. Note that the binary output is already generated at this point so the changes wouldn't take effect.
I would recommend that you use ItemDataBound and ItemCreated events instead.

Regards,
Daniel
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
Ken Lassesen
Top achievements
Rank 2
Answers by
Daniel
Telerik team
Share this question
or