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

[Solved] Custom Header is no longer exported with the Grid.

4 Answers 98 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Michael Hunt
Top achievements
Rank 1
Michael Hunt asked on 25 Jun 2014, 02:42 PM
Hi,

I am using version 2013.3.1114.35 of your ASP.NET for AJAX controls.

In the past, you have implemented the following awesome workaround, to allow a custom header to be exported, when exporting from a grid.

protected void RadGrid1_GridExporting(object source, GridExportingArgs e)
 {
     string customHeader = "<table><tr><td>CUSTOM HEADER</td></tr></table>";
     e.ExportOutput = e.ExportOutput.Replace("<table cellspacing", customHeader + "<table cellspacing");
 }

I implemented that years ago and it had been working for a long time.  However, it no longer works.  The code runs without error, but the Custom Header is NOT exported.  Only the report data is exported...

For us I don't know exactly when it broke, but I would suspect it was when we upgraded to 2013.3.1114.35.  

Q.  Can you confirm this?
Q.  Can you suggest a "fix"?  Perhaps I just need a different customHeader string???

Any help is appreciated.

Regards,
Michael

4 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 26 Jun 2014, 06:37 AM
Hi Michael Hunt,

I'm not sure which export you are performing. In case if you are using PDF export, it has properties to set the PDF header text. If in case of Excel export you can try to set the caption.

ASPX:
<ExportSettings>
  <Pdf PageHeader-MiddleCell-Text="CUSTOM HEADER">
  </Pdf>
</ExportSettings>

OR

C#:
protected void RadGrid1_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
{
 if (e.CommandName == RadGrid.ExportToExcelCommandName)
 {
   RadGrid1.MasterTableView.Caption = "<span><br/>Custom Header</span>";
 }
}

Please provide more information if this doesn't help.

Thanks,
Princy
0
Michael Hunt
Top achievements
Rank 1
answered on 26 Jun 2014, 12:18 PM
Hi Princy,

I am exporting to Excel and Word.

I will try what you've included in the ItemCommand.

However, you are familiar with the code example I put in my original post, correct?  That code (or similar) is what you all have suggested in the forums, to add a custom header to the grid as it is being exported.

I was wondering if something was done in some release of your controls, that "broke" that functionality.  I ask that because I've implemented it on at least 10 grids and it was working on all of them, and now it doesn't print my custom header on any of them.

Thanks,
Michael
0
Michael Hunt
Top achievements
Rank 1
answered on 26 Jun 2014, 01:01 PM
Hi Princy,

Your ItemCommand code does allow me to add a custom header to the export.  So I guess that now is the preferred way to do it.

It's unfortunate that the previous way to do it (the workaround suggested in many other older forum posts) seems to no longer work...

Thanks,
Michael
0
Kostadin
Telerik team
answered on 01 Jul 2014, 08:47 AM
Hello Michael,

It looks like the rendered html of the grid has been changed and the string which you are trying to replace could not be found ("<table cellspacing") and the change is not done. Nevertheless you could use the Princy's approach to achieve the desired requirement.

Regards,
Kostadin
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
Michael Hunt
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Michael Hunt
Top achievements
Rank 1
Kostadin
Telerik team
Share this question
or