Hello,
I have a grid that has sorting, filtering and export to excel functionality by design. This grid is part of a user control page that is loaded inside of a content asp panel from the parent page. The default.aspx page has the script manager and radajax manager, the later is configured to update the content page when the header or footer are clicked but not it self.
The issue i am having is I cant seem to be able to trigger the export to excel function of the grid. It works fine in a aspx page, but not at all in my usercontrol.
I have read all the posted information and reviewed all available projects regarding working with export in ajax projects. The closest one i saw is exporting from a content page that is loaded by a master page, however that example didn't work either for my practicular environment.
I tried using Ajax Manager Proxy but no luck so far. Can you please post an example of how to make the export work for a usercontrol scenario in C#?
Update : I managed to get it to work somewhat except it only works on the 2nd click of the btnExcel and every click there after.
This is my code:
Reports.ascx.cs
Reports.aspx:
Default.aspx:
As expected after that the sorting, view details and the whole webpage navigation stops working because the ajax remains disabled.
Can you please help me correct that behaviour so it actualy works on the first click and does not affect the rest of the application functionality?
Blagodaria vi mnogo za vremeto vi I se izveniavam za bezpokoistvoto.
I have a grid that has sorting, filtering and export to excel functionality by design. This grid is part of a user control page that is loaded inside of a content asp panel from the parent page. The default.aspx page has the script manager and radajax manager, the later is configured to update the content page when the header or footer are clicked but not it self.
The issue i am having is I cant seem to be able to trigger the export to excel function of the grid. It works fine in a aspx page, but not at all in my usercontrol.
I have read all the posted information and reviewed all available projects regarding working with export in ajax projects. The closest one i saw is exporting from a content page that is loaded by a master page, however that example didn't work either for my practicular environment.
I tried using Ajax Manager Proxy but no luck so far. Can you please post an example of how to make the export work for a usercontrol scenario in C#?
Update : I managed to get it to work somewhat except it only works on the 2nd click of the btnExcel and every click there after.
This is my code:
Reports.ascx.cs
protected void btnExcel_Click(object sender, EventArgs e) |
{ |
RadAjaxManager ram = (RadAjaxManager)this.Page.FindControl("ramManager"); |
ram.EnableAJAX = false; |
gReports.PageSize = gReports.MasterTableView.VirtualItemCount; |
gReports.ExportSettings.IgnorePaging = true; |
gReports.ExportSettings.ExportOnlyData = true; |
gReports.MasterTableView.ExportToExcel(); |
} |
Reports.aspx:
<asp:Button ID="btnExcel" Width="150px" Text="Export to Excel" CommandName="Export" runat="server" OnClick="btnExcel_Click" /> | |
<telerik:RadGrid ID="gReports" ShowStatusBar="True" Skin="WebBlue" GridLines="None" | |
AllowSorting="True" AllowPaging="True" PageSize="20" Width="100%" runat="server" | |
AllowFilteringByColumn="True" AutoGenerateColumns="False" ItemStyle-Wrap="false" | |
OnItemCommand="gReports_ItemCommand"> | |
<MasterTableView TableLayout="Auto" DataKeyNames="service_request_id" CellPadding="3" GridLines="None"> | |
<Columns> | |
<telerik:GridTemplateColumn UniqueName="ViewRequestColumn" AllowFiltering="False" HeaderStyle-Width="30px" ItemStyle-Width="30px"> | |
<ItemTemplate> | |
<asp:LinkButton ID="lbView" runat="server" CommandName="ShowDetails">View</asp:LinkButton> | |
</ItemTemplate> | |
<HeaderStyle Width="30px" /> | |
<ItemStyle Width="30px" /> | |
</telerik:GridTemplateColumn> | |
<telerik:GridBoundColumn HeaderText="Claim Number" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" | |
DataField="claim_no" UniqueName="claim_no"> | |
</telerik:GridBoundColumn> | |
</Columns> | |
</MasterTableView> | |
<ClientSettings> | |
<Selecting AllowRowSelect="True" EnableDragToSelectRows="False" /> | |
<Scrolling AllowScroll="True" ScrollHeight="457px" UseStaticHeaders="True" SaveScrollPosition="True"> | |
</Scrolling> | |
</ClientSettings> | |
</telerik:RadGrid> |
Default.aspx:
<telerik:RadScriptManager ID="RadScriptManager" runat="server" /> |
<telerik:RadAjaxManager ID="ramManager" runat="server" > |
<AjaxSettings> |
<telerik:AjaxSetting AjaxControlID="pHeader"> |
<UpdatedControls> |
<telerik:AjaxUpdatedControl ControlID="rapCrumb" /> |
<telerik:AjaxUpdatedControl ControlID="rapContent" LoadingPanelID="rlpLoading" /> |
</UpdatedControls> |
</telerik:AjaxSetting> |
<telerik:AjaxSetting AjaxControlID="pFooter"> |
<UpdatedControls> |
<telerik:AjaxUpdatedControl ControlID="rapCrumb" /> |
<telerik:AjaxUpdatedControl ControlID="rapContent" LoadingPanelID="rlpLoading" /> |
</UpdatedControls> |
</telerik:AjaxSetting> |
</AjaxSettings> |
</telerik:RadAjaxManager> |
<div id="dFrame"> |
<div id="dContent"> |
<asp:Panel ID="rapContent" runat="server"> |
</asp:Panel> |
</div> |
Can you please help me correct that behaviour so it actualy works on the first click and does not affect the rest of the application functionality?
Blagodaria vi mnogo za vremeto vi I se izveniavam za bezpokoistvoto.