3 Answers, 1 is accepted
0

Princy
Top achievements
Rank 2
answered on 15 Jan 2014, 05:08 AM
Hi Leon,
Below is a sample code snippet that i tried and i couldn't replicate the issue you were saying. Please try the code snippet and provide your code snippet if this doesn't help:
ASPX:
C#:
Thanks,
Princy
Below is a sample code snippet that i tried and i couldn't replicate the issue you were saying. Please try the code snippet and provide your code snippet if this doesn't help:
ASPX:
<
telerik:RadGrid
ID
=
"RadGrid1"
runat
=
"server"
AutoGenerateColumns
=
"true"
AllowPaging
=
"true"
GridLines
=
"None"
OnNeedDataSource
=
"RadGrid1_NeedDataSource"
>
<
ExportSettings
ExportOnlyData
=
"true"
>
</
ExportSettings
>
<
MasterTableView
CommandItemDisplay
=
"Top"
>
<
CommandItemSettings
ShowExportToExcelButton
=
"true"
ShowExportToPdfButton
=
"true"
/>
</
MasterTableView
>
</
telerik:RadGrid
>
C#:
protected
void
RadGrid1_NeedDataSource(
object
sender, GridNeedDataSourceEventArgs e)
{
dynamic data =
new
[] {
new
{ ID = 1, Name =
"Name1"
, Number=123},
new
{ ID = 2, Name =
"Name2"
, Number=234},
new
{ ID = 3, Name =
"Name3"
, Number=234},
new
{ ID = 4, Name =
"Name4"
, Number=456},
new
{ ID = 5, Name =
"Name5"
, Number=567},
new
{ ID = 6, Name =
"Name6"
, Number=567},
new
{ ID = 7, Name =
"Name7"
, Number=789},
new
{ ID = 8, Name =
"Name8"
, Number=896},
new
{ ID = 9, Name =
"Name9"
, Number=741}
};
RadGrid1.DataSource = data;
}
Thanks,
Princy
0

Leon
Top achievements
Rank 1
answered on 15 Jan 2014, 06:22 AM
Hi princy.
Thank you for the reply, fortunately I have found what the error was, for some odd reason I was using GridAttachmentColumn's instead of GridBoundColumns, which then seemed to make the data hyperlinks. Now that that issue has been resolved, do you perhaps have an idea on how to solve the following:
1) When exporting to CSV, <nobr> and </nobr> tags are added to the data
2) Column headings are not aligned with the data in a PDF export.
Kind regards.
Leon Havenga
Thank you for the reply, fortunately I have found what the error was, for some odd reason I was using GridAttachmentColumn's instead of GridBoundColumns, which then seemed to make the data hyperlinks. Now that that issue has been resolved, do you perhaps have an idea on how to solve the following:
1) When exporting to CSV, <nobr> and </nobr> tags are added to the data
2) Column headings are not aligned with the data in a PDF export.
Kind regards.
Leon Havenga
0

Princy
Top achievements
Rank 2
answered on 16 Jan 2014, 06:40 AM
Hi Leon,
For your first issue can you try setting ExportOnlyData="true" ,the CSV export of the grid takes the string representation of the cell content (as opposed to Excel/Word/PDF export which operated with the rendered html) and that is the reason the nobr tags are part of the exported data.
For aligning the column headings for PDF export please try the following code snippet:
C#:
Thanks,
Princy
For your first issue can you try setting ExportOnlyData="true" ,the CSV export of the grid takes the string representation of the cell content (as opposed to Excel/Word/PDF export which operated with the rendered html) and that is the reason the nobr tags are part of the exported data.
For aligning the column headings for PDF export please try the following code snippet:
C#:
public
static
bool
IsPDFExport=
false
;
protected
void
RadGrid1_ItemCommand(
object
sender, GridCommandEventArgs e)
{
if
(e.CommandName == RadGrid.ExportToPdfCommandName)
{
IsPDFExport =
true
;
}
}
protected
void
RadGrid1_PreRender(
object
sender, EventArgs e)
{
if
(IsPDFExport)
{
foreach
(GridHeaderItem header
in
RadGrid1.MasterTableView.GetItems(GridItemType.Header))
{
foreach
(TableCell cell
in
header.Cells)
{
cell.Style[
"text-align"
] =
"left"
;
}
}
}
}
Thanks,
Princy