Hello,
I'm having issues with exporting to Excel or PDF when the user clicks on a linkbutton in the commanditemtemplate of RadGrid1. The RadGrid appears to refresh, and then is completely loaded without paging enabled. The commanditemdisplay is not displaying anymore either (I display the commanditems based on access levels). I can fix this issue by removing RadGrid1 from the UpdateControls part of RadAjaxManager1; however, I need RadGrid1 to be updated when there is an ajaxRequest initiated by closing a Radwindow. Here is my code related to this issue. Please let me know how I can achieve exporting to Excel and PDF while keeping RadGrid1 in the RadAjaxManager1 updated controls section. I put a breakpoint on RadAjaxManager1_AjaxRequest, but it was never hit.
Thanks,
Casey
RadAjaxManager1:
Javascript to initiate ajaxRequest:
Code-Behind executed onAjaxRequest:
RadGrid1:
LinkButton CodeBehind:
I'm having issues with exporting to Excel or PDF when the user clicks on a linkbutton in the commanditemtemplate of RadGrid1. The RadGrid appears to refresh, and then is completely loaded without paging enabled. The commanditemdisplay is not displaying anymore either (I display the commanditems based on access levels). I can fix this issue by removing RadGrid1 from the UpdateControls part of RadAjaxManager1; however, I need RadGrid1 to be updated when there is an ajaxRequest initiated by closing a Radwindow. Here is my code related to this issue. Please let me know how I can achieve exporting to Excel and PDF while keeping RadGrid1 in the RadAjaxManager1 updated controls section. I put a breakpoint on RadAjaxManager1_AjaxRequest, but it was never hit.
Thanks,
Casey
RadAjaxManager1:
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" |
OnAjaxRequest="RadAjaxManager1_AjaxRequest"> |
<AjaxSettings> |
<telerik:AjaxSetting AjaxControlID="RadAjaxManager1"> |
<UpdatedControls> |
<telerik:AjaxUpdatedControl ControlID="DateTime" /> |
<telerik:AjaxUpdatedControl ControlID="RadGrid2" /> |
<telerik:AjaxUpdatedControl ControlID="lblNote" /> |
<telerik:AjaxUpdatedControl ControlID="Note" /> |
<telerik:AjaxUpdatedControl ControlID="RequiredFieldValidator1" /> |
<telerik:AjaxUpdatedControl ControlID="RadGrid1" /> |
</UpdatedControls> |
</telerik:AjaxSetting> |
<telerik:AjaxSetting AjaxControlID="RadGrid2"> |
<UpdatedControls> |
<telerik:AjaxUpdatedControl ControlID="lblNote" /> |
<telerik:AjaxUpdatedControl ControlID="Note" /> |
<telerik:AjaxUpdatedControl ControlID="RequiredFieldValidator1" /> |
</UpdatedControls> |
</telerik:AjaxSetting> |
</AjaxSettings> |
</telerik:RadAjaxManager> |
Javascript to initiate ajaxRequest:
function refreshGrid() { |
$find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("Rebind"); |
} |
Code-Behind executed onAjaxRequest:
protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e) |
{ |
if (e.Argument.ToString() == "Rebind") |
{ |
foreach (GridDataItem i in RadGrid2.Items) |
{ |
if (i.Selected) |
{ |
SqlDataSource3.Insert(); |
i.Selected = false; |
} |
} |
RequiredFieldValidator1.Enabled = false; |
RadGrid1.Rebind(); |
} |
} |
RadGrid1:
<telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="False" |
GridLines="None" Skin="Office2007" ItemStyle-Wrap="true" |
DataSourceID="SqlDataSource1" oninit="RadGrid1_Init" |
AllowSorting="True" onitemcreated="RadGrid1_ItemCreated" |
AllowFilteringByColumn="True" AllowPaging="True" Width="100%" |
OnItemDataBound="RadGrid1_ItemDataBound"> |
<ItemStyle Wrap="True"></ItemStyle> |
<MasterTableView CellSpacing="-1" DataSourceID="SqlDataSource1" |
AllowSorting="true" |
CommandItemDisplay="None" ItemStyle-Wrap="true"> |
<ItemStyle Wrap="True"></ItemStyle> |
<CommandItemTemplate> |
<table width="100%"> |
<tr> |
<td align="right"> |
<asp:LinkButton ID="Excel" runat="server" Font-Bold="True" |
CausesValidation="False" Height="10px" |
OnClick="Excel_Click">Export to Excel</asp:LinkButton> |
|
<asp:LinkButton ID="PDF" runat="server" Font-Bold="True" |
CausesValidation="False" Height="10px" |
OnClick="PDF_Click">Export to PDF</asp:LinkButton> |
</td> |
</tr> |
</table> |
</CommandItemTemplate> |
<Columns> |
... |
</Columns> |
</MasterTableView> |
</telerik:RadGrid> |
LinkButton CodeBehind:
protected void Excel_Click(object sender, EventArgs e) |
{ |
ConfigureExport(); |
RadGrid1.MasterTableView.ExportToExcel(); |
} |
protected void PDF_Click(object sender, EventArgs e) |
{ |
ConfigureExport(); |
RadGrid1.ExportSettings.Pdf.PageWidth = Unit.Pixel(1500); |
RadGrid1.MasterTableView.ExportToPdf(); |
} |
public void ConfigureExport() |
{ |
RadGrid1.ExportSettings.ExportOnlyData = true; |
RadGrid1.ExportSettings.IgnorePaging = true; |
RadGrid1.ExportSettings.OpenInNewWindow = true; |
} |