Hi,
we are facing formatting issues while exporting the GRID to PDF.
some of the columns in the grid are not shown in the PDF. This problem exist if we have more than 3 columns in the grid.
Export to Excel & Export to Word are working properly.
Below is the code we are using.
In .aspx
<telerik:RadGrid ID="rdgRoles" runat="server" DataSourceID="dsRoles" OnItemCommand="RdgRolesItemCommand" Width="990px"
ValidationSettings-ValidationGroup="valgrpSettings">
<MasterTableView AutoGenerateColumns="false" DataKeyNames="RoleId" CommandItemDisplay="Top"
CommandItemSettings-AddNewRecordImageUrl="../Images/App/addRole.png" CommandItemSettings-AddNewRecordText=""
PagerStyle-AlwaysVisible="True" AllowPaging="True" AllowSorting="true">
<CommandItemSettings ShowExportToExcelButton="True" ShowExportToWordButton="True"
ShowExportToPdfButton="True" ShowRefreshButton="False"></CommandItemSettings>
<Columns>
<telerik:GridTemplateColumn UniqueName="template" HeaderStyle-Width="50px" ItemStyle-Width="50px">
<ItemTemplate>
<asp:ImageButton ID="imgEdit" runat="server" ToolTip="Edit" CommandName="EditRole"
ImageUrl="~/Images/App/icon_edit.gif" />
<asp:ImageButton ID="imgbtnDelete" ToolTip="Delete" runat="server" CommandName="Delete"
ImageUrl="~/Images/App/icon_delete.gif" OnClientClick="return confirm('Are you sure want to Delete this Role?');" />
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn HeaderText="Role" HeaderStyle-Width="200px" ItemStyle-Width="200px" SortExpression="Role" >
<ItemTemplate>
<span class="wordwrapcontentnormal" style="width:200px;">
<asp:Label ID="lblRole" runat="server" Text='<%# Bind("Role") %>'></asp:Label>
</span>
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridBoundColumn HeaderText="Description" DataField="Description" MaxLength="500" HeaderStyle-Width="300px" ItemStyle-Width="300px">
</telerik:GridBoundColumn>
<telerik:GridTemplateColumn HeaderText="Permission Level" HeaderStyle-Width="200px" ItemStyle-Width="200px" SortExpression="PermissionLevel">
<ItemTemplate>
<span class="wordwrapcontentnormal" style="width:200px;">
<asp:Label ID="lblPermission" runat="server" Text='<%# Eval("PermissionLevel") %>'></asp:Label>
</span>
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridCheckBoxColumn UniqueName="Active" HeaderText="Active" DataField="Active" HeaderStyle-Width="50px" ItemStyle-Width="50px">
</telerik:GridCheckBoxColumn>
<telerik:GridTemplateColumn UniqueName="ActiveString" HeaderText="Active" HeaderStyle-Width="50px" ItemStyle-Width="50px" Visible="false" ItemStyle-VerticalAlign="Top">
<ItemTemplate>
<%# Eval("ActiveString") %>
</ItemTemplate>
</telerik:GridTemplateColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>
In Code behind
protected void RdgRolesItemCommand(object source, GridCommandEventArgs e)
{
try
{
if (e.CommandName == RadGrid.ExportToExcelCommandName ||
e.CommandName == RadGrid.ExportToWordCommandName ||
e.CommandName == RadGrid.ExportToCsvCommandName ||
e.CommandName == RadGrid.ExportToPdfCommandName)
{
rdgRoles.ExportSettings.ExportOnlyData = true;
rdgRoles.ExportSettings.IgnorePaging = true;
rdgRoles.ExportSettings.OpenInNewWindow = true;
rdgRoles.ExportSettings.FileName = GlobalHelper.ExportFileName(Resources.Messages.RoleExportFileName);
GlobalHelper.IsExport = true;
rdgRoles.MasterTableView.GetColumn("template").Visible = false;
rdgRoles.MasterTableView.GetColumn("Active").Visible = false;
rdgRoles.MasterTableView.GetColumn("ActiveString").Visible = true;
}
switch (e.CommandName)
{
case RadGrid.ExportToExcelCommandName:
rdgRoles.MasterTableView.ExportToExcel();
break;
case RadGrid.ExportToCsvCommandName:
rdgRoles.ExportSettings.ExportOnlyData = false;
rdgRoles.MasterTableView.ExportToCSV();
break;
case RadGrid.ExportToPdfCommandName:
rdgRoles.MasterTableView.ExportToPdf();
break;
case RadGrid.ExportToWordCommandName:
rdgRoles.MasterTableView.ExportToWord();
break;
}
}
catch (Exception ex)
{
}
}
Can you please provide solution for this?
Thanks in advance.
we are facing formatting issues while exporting the GRID to PDF.
some of the columns in the grid are not shown in the PDF. This problem exist if we have more than 3 columns in the grid.
Export to Excel & Export to Word are working properly.
Below is the code we are using.
In .aspx
<telerik:RadGrid ID="rdgRoles" runat="server" DataSourceID="dsRoles" OnItemCommand="RdgRolesItemCommand" Width="990px"
ValidationSettings-ValidationGroup="valgrpSettings">
<MasterTableView AutoGenerateColumns="false" DataKeyNames="RoleId" CommandItemDisplay="Top"
CommandItemSettings-AddNewRecordImageUrl="../Images/App/addRole.png" CommandItemSettings-AddNewRecordText=""
PagerStyle-AlwaysVisible="True" AllowPaging="True" AllowSorting="true">
<CommandItemSettings ShowExportToExcelButton="True" ShowExportToWordButton="True"
ShowExportToPdfButton="True" ShowRefreshButton="False"></CommandItemSettings>
<Columns>
<telerik:GridTemplateColumn UniqueName="template" HeaderStyle-Width="50px" ItemStyle-Width="50px">
<ItemTemplate>
<asp:ImageButton ID="imgEdit" runat="server" ToolTip="Edit" CommandName="EditRole"
ImageUrl="~/Images/App/icon_edit.gif" />
<asp:ImageButton ID="imgbtnDelete" ToolTip="Delete" runat="server" CommandName="Delete"
ImageUrl="~/Images/App/icon_delete.gif" OnClientClick="return confirm('Are you sure want to Delete this Role?');" />
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn HeaderText="Role" HeaderStyle-Width="200px" ItemStyle-Width="200px" SortExpression="Role" >
<ItemTemplate>
<span class="wordwrapcontentnormal" style="width:200px;">
<asp:Label ID="lblRole" runat="server" Text='<%# Bind("Role") %>'></asp:Label>
</span>
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridBoundColumn HeaderText="Description" DataField="Description" MaxLength="500" HeaderStyle-Width="300px" ItemStyle-Width="300px">
</telerik:GridBoundColumn>
<telerik:GridTemplateColumn HeaderText="Permission Level" HeaderStyle-Width="200px" ItemStyle-Width="200px" SortExpression="PermissionLevel">
<ItemTemplate>
<span class="wordwrapcontentnormal" style="width:200px;">
<asp:Label ID="lblPermission" runat="server" Text='<%# Eval("PermissionLevel") %>'></asp:Label>
</span>
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridCheckBoxColumn UniqueName="Active" HeaderText="Active" DataField="Active" HeaderStyle-Width="50px" ItemStyle-Width="50px">
</telerik:GridCheckBoxColumn>
<telerik:GridTemplateColumn UniqueName="ActiveString" HeaderText="Active" HeaderStyle-Width="50px" ItemStyle-Width="50px" Visible="false" ItemStyle-VerticalAlign="Top">
<ItemTemplate>
<%# Eval("ActiveString") %>
</ItemTemplate>
</telerik:GridTemplateColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>
In Code behind
protected void RdgRolesItemCommand(object source, GridCommandEventArgs e)
{
try
{
if (e.CommandName == RadGrid.ExportToExcelCommandName ||
e.CommandName == RadGrid.ExportToWordCommandName ||
e.CommandName == RadGrid.ExportToCsvCommandName ||
e.CommandName == RadGrid.ExportToPdfCommandName)
{
rdgRoles.ExportSettings.ExportOnlyData = true;
rdgRoles.ExportSettings.IgnorePaging = true;
rdgRoles.ExportSettings.OpenInNewWindow = true;
rdgRoles.ExportSettings.FileName = GlobalHelper.ExportFileName(Resources.Messages.RoleExportFileName);
GlobalHelper.IsExport = true;
rdgRoles.MasterTableView.GetColumn("template").Visible = false;
rdgRoles.MasterTableView.GetColumn("Active").Visible = false;
rdgRoles.MasterTableView.GetColumn("ActiveString").Visible = true;
}
switch (e.CommandName)
{
case RadGrid.ExportToExcelCommandName:
rdgRoles.MasterTableView.ExportToExcel();
break;
case RadGrid.ExportToCsvCommandName:
rdgRoles.ExportSettings.ExportOnlyData = false;
rdgRoles.MasterTableView.ExportToCSV();
break;
case RadGrid.ExportToPdfCommandName:
rdgRoles.MasterTableView.ExportToPdf();
break;
case RadGrid.ExportToWordCommandName:
rdgRoles.MasterTableView.ExportToWord();
break;
}
}
catch (Exception ex)
{
}
}
Can you please provide solution for this?
Thanks in advance.