I have a hierarchical grid and when i am exporting it to excel, resulted excel contains not working hyperlinks in header row.
I need to remove these links and need to show as a normal text header.
In my rad grid sorting is enabled.
Please give me a solution how to replace header.
I need to remove these links and need to show as a normal text header.
In my rad grid sorting is enabled.
Please give me a solution how to replace header.
3 Answers, 1 is accepted
0

Shinu
Top achievements
Rank 2
answered on 13 Dec 2010, 12:16 PM
Hello Madhu,
If you want to remove the underline in HeaderText, set ExportOnlyData property of ExportSettings as 'true'.
ASPX:
-Shinu.
If you want to remove the underline in HeaderText, set ExportOnlyData property of ExportSettings as 'true'.
ASPX:
<
telerik:RadGrid
ID
=
"RadGrid1"
>
<
ExportSettings
OpenInNewWindow
=
"true"
ExportOnlyData
=
"true"
>
</
ExportSettings
>
. . . . . .
-Shinu.
0

madu
Top achievements
Rank 1
answered on 13 Dec 2010, 01:49 PM
Thanks Shinu for your reply
But it did not work.I replace grid header by hard coding as follows.It also did not work when there are few grids (I am exporting hierarchical grid)
And also this hard coded string value is too much long.If I need to add a column to my grid It will be very difficult to change these strings.
Please give me a better solution to achieve my goal as this is an urgent fix for production environment.
Thanks
Madu.
But it did not work.I replace grid header by hard coding as follows.It also did not work when there are few grids (I am exporting hierarchical grid)
And also this hard coded string value is too much long.If I need to add a column to my grid It will be very difficult to change these strings.
Please give me a better solution to achieve my goal as this is an urgent fix for production environment.
protected
void
RadGrid2_GridExporting(
object
source, Telerik.Web.UI.GridExportingArgs e) {
string
oldHeader =
"<th scope="
+
"\""
+
"col"
+
"\""
+
"><a title="
+
"\""
+
"Click here to sort"
+
"\""
+
" href="
+
"\""
+
"javascript:__doPostBack('ctl00$BodyContentPlaceholder$RadGrid2$ctl00$ctl06$Detail10$ctl02$ctl00$ctl00','')"
+
"\""
+
">ID</a></th><th scope="
+
"\""
+
"col"
+
"\""
+
"><a title="
+
"\""
+
"Click here to sort"
+
"\""
+
" href="
+
"\""
+
"javascript:__doPostBack('ctl00$BodyContentPlaceholder$RadGrid2$ctl00$ctl06$Detail10$ctl02$ctl00$ctl01','')"
+
"\""
+
">First Name</a></th><th scope="
+
"\""
+
"col"
+
"\""
+
"><a title="
+
"\""
+
"Click here to sort"
+
"\""
+
" href="
+
"\""
+
"javascript:__doPostBack('ctl00$BodyContentPlaceholder$RadGrid2$ctl00$ctl06$Detail10$ctl02$ctl00$ctl02','')"
+
"\""
+
">Last Name</a></th><th scope="
+
"\""
+
"col"
+
"\""
+
"><a title="
+
"\""
+
"Click here to sort"
+
"\""
+
" href="
+
"\""
+
"javascript:__doPostBack('ctl00$BodyContentPlaceholder$RadGrid2$ctl00$ctl06$Detail10$ctl02$ctl00$ctl04','')"
+
"\""
+
">Contact Email</a></th><th scope="
+
"\""
+
"col"
+
"\""
+
"><a title="
+
"\""
+
"Click here to sort"
+
"\""
+
" href="
+
"\""
+
"javascript:__doPostBack('ctl00$BodyContentPlaceholder$RadGrid2$ctl00$ctl06$Detail10$ctl02$ctl00$ctl05','')"
+
"\""
+
">Contact Phone</a></th><th scope="
+
"\""
+
"col"
+
"\""
+
"><a title="
+
"\""
+
"Click here to sort"
+
"\""
+
" href="
+
"\""
+
"javascript:__doPostBack('ctl00$BodyContentPlaceholder$RadGrid2$ctl00$ctl06$Detail10$ctl02$ctl00$ctl06','')"
+
"\""
+
">Date Created</a></th><th scope="
+
"\""
+
"col"
+
"\""
+
"><a title="
+
"\""
+
"Click here to sort"
+
"\""
+
" href="
+
"\""
+
"javascript:__doPostBack('ctl00$BodyContentPlaceholder$RadGrid2$ctl00$ctl06$Detail10$ctl02$ctl00$ctl07','')"
+
"\""
+
">Survey Id</a></th><th scope="
+
"\""
+
"col"
+
"\""
+
"><a title="
+
"\""
+
"Click here to sort"
+
"\""
+
" href="
+
"\""
+
"javascript:__doPostBack('ctl00$BodyContentPlaceholder$RadGrid2$ctl00$ctl06$Detail10$ctl02$ctl00$ctl08','')"
+
"\""
+
">Additional Status</a></th><th scope="
+
"\""
+
"col"
+
"\""
+
"><a title="
+
"\""
+
"Click here to sort"
+
"\""
+
" href="
+
"\""
+
"javascript:__doPostBack('ctl00$BodyContentPlaceholder$RadGrid2$ctl00$ctl06$Detail10$ctl02$ctl00$ctl09','')"
+
"\""
+
">Division</a></th><th scope="
+
"\""
+
"col"
+
"\""
+
"><a title="
+
"\""
+
"Click here to sort"
+
"\""
+
" href="
+
"\""
+
"javascript:__doPostBack('ctl00$BodyContentPlaceholder$RadGrid2$ctl00$ctl06$Detail10$ctl02$ctl00$ctl10','')"
+
"\""
+
">Business Unit</a></th><th scope="
+
"\""
+
"col"
+
"\""
+
"><a title="
+
"\""
+
"Click here to sort"
+
"\""
+
" href="
+
"\""
+
"javascript:__doPostBack('ctl00$BodyContentPlaceholder$RadGrid2$ctl00$ctl06$Detail10$ctl02$ctl00$ctl11','')"
+
"\""
+
">Company Name</a></th><th scope="
+
"\""
+
"col"
+
"\""
+
"><a title="
+
"\""
+
"Click here to sort"
+
"\""
+
" href="
+
"\""
+
"javascript:__doPostBack('ctl00$BodyContentPlaceholder$RadGrid2$ctl00$ctl06$Detail10$ctl02$ctl00$ctl12','')"
+
"\""
+
">Area</a></th><th scope="
+
"\""
+
"col"
+
"\""
+
"><a title="
+
"\""
+
"Click here to sort"
+
"\""
+
" href="
+
"\""
+
"javascript:__doPostBack('ctl00$BodyContentPlaceholder$RadGrid2$ctl00$ctl06$Detail10$ctl02$ctl00$ctl13','')"
+
"\""
+
">Business Segment Level1</a></th><th scope="
+
"\""
+
"col"
+
"\""
+
"><a title="
+
"\""
+
"Click here to sort"
+
"\""
+
" href="
+
"\""
+
"javascript:__doPostBack('ctl00$BodyContentPlaceholder$RadGrid2$ctl00$ctl06$Detail10$ctl02$ctl00$ctl14','')"
+
"\""
+
">Business Segment Level2</a></th><th scope="
+
"\""
+
"col"
+
"\""
+
"><a title="
+
"\""
+
"Click here to sort"
+
"\""
+
" href="
+
"\""
+
"javascript:__doPostBack('ctl00$BodyContentPlaceholder$RadGrid2$ctl00$ctl06$Detail10$ctl02$ctl00$ctl15','')"
+
"\""
+
">Channel</a></th><th scope="
+
"\""
+
"col"
+
"\""
+
"><a title="
+
"\""
+
"Click here to sort"
+
"\""
+
" href="
+
"\""
+
"javascript:__doPostBack('ctl00$BodyContentPlaceholder$RadGrid2$ctl00$ctl06$Detail10$ctl02$ctl00$ctl16','')"
+
"\""
+
">Customer Market Group</a></th><th scope="
+
"\""
+
"col"
+
"\""
+
"><a title="
+
"\""
+
"Click here to sort"
+
"\""
+
" href="
+
"\""
+
"javascript:__doPostBack('ctl00$BodyContentPlaceholder$RadGrid2$ctl00$ctl06$Detail10$ctl02$ctl00$ctl17','')"
+
"\""
+
">Sales Manager</a></th><th scope="
+
"\""
+
"col"
+
"\""
+
"><a title="
+
"\""
+
"Click here to sort"
+
"\""
+
" href="
+
"\""
+
"javascript:__doPostBack('ctl00$BodyContentPlaceholder$RadGrid2$ctl00$ctl06$Detail10$ctl02$ctl00$ctl18','')"
+
"\""
+
">SO Branch FO Desc</a></th><th scope="
+
"\""
+
"col"
+
"\""
+
"><a title="
+
"\""
+
"Click here to sort"
+
"\""
+
" href="
+
"\""
+
"javascript:__doPostBack('ctl00$BodyContentPlaceholder$RadGrid2$ctl00$ctl06$Detail10$ctl02$ctl00$ctl19','')"
+
"\""
+
">SO Branch FO Num</a></th><th scope="
+
"\""
+
"col"
+
"\""
+
"><a title="
+
"\""
+
"Click here to sort"
+
"\""
+
" href="
+
"\""
+
"javascript:__doPostBack('ctl00$BodyContentPlaceholder$RadGrid2$ctl00$ctl06$Detail10$ctl02$ctl00$ctl20','')"
+
"\""
+
">Zone Sales Region Hub</a></th><th scope="
+
"\""
+
"col"
+
"\""
+
"><a title="
+
"\""
+
"Click here to sort"
+
"\""
+
" href="
+
"\""
+
"javascript:__doPostBack('ctl00$BodyContentPlaceholder$RadGrid2$ctl00$ctl06$Detail10$ctl02$ctl00$ctl21','')"
+
"\""
+
">Comments</a></th>"
;
string
newHeader =
"<th scope='col'>ID</th><th scope='col'>First Name</th><th scope='col'>Last Name</th> <th scope='col'>Contact Email</th><th scope='col'>Contact Phone</th> <th scope='col'>Date Created</th> <th scope='col'>Survey Id</th> <th scope='col'>Additional Status</th> <th scope='col'>Division</th> <th scope='col'>Business Unit</th> <th scope='col'>Company Name</th> <th scope='col'>Area</th><th scope='col'>Business Segment Level1</th><th scope='col'>Business Segment Level2</th> <th scope='col'>Channel</th><th scope='col'>Customer Market Group</th><th scope='col'>Sales Manager</th><th scope='col'>SO Branch FO Desc</th><th scope='col'>SO Branch FO Num</th> <th scope='col'>Zone Sales Region Hub</th><th scope='col'>Comments</th>"
;
e.ExportOutput = e.ExportOutput.Replace(oldHeader, newHeader);
}
Thanks
Madu.
0

madu
Top achievements
Rank 1
answered on 14 Dec 2010, 09:12 AM
Hi All
Finally I found a solution...Hope it will be helpful you guys also.
Regards,
Madu
Finally I found a solution...Hope it will be helpful you guys also.
protected
void
RadGrid2_ItemDataBound(
object
sender,Telerik.Web.UI.GridItemEventArgs e)
{
//turn off the hyperlinks in header in the excel file.
if
(e.Item
is
GridHeaderItem && isExport)
foreach
(TableCell cell
in
e.Item.Cells)
{
if
(cell.HasControls() && cell.Controls[0]
is
HyperLink)
cell.Text = (cell.Controls[0]
as
LinkButton).Text;
//if first control in cell is not linkbutton.
else
if
(cell.HasControls())
{
string
txtTot =
string
.Empty;
foreach
(Control con
in
cell.Controls)
{
if
(con
is
LiteralControl)
txtTot += (con
as
LiteralControl).Text;
if
(con
is
LinkButton)
//it looses formatting for some reason, so added bold tags.
txtTot +=
"<b>"
+ (con
as
LinkButton).Text +
"</b>"
;
}
cell.Text = txtTot;
}
//end of if first control in cell is not linkbutton.
}
// end of for each cell in header
}
Regards,
Madu