This is a migrated thread and some comments may be shown as answers.

Can RadGrid.MasterTableView.ExportToExcel() work with RestoreOriginalRenderDelegate="true"

1 Answer 212 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Aaron
Top achievements
Rank 1
Aaron asked on 04 Oct 2011, 04:36 PM
I have a radgrid that I would like to have the data be exported to an excel document using RadGrid.MasterTableView.ExportToExcel().  The RadGrid contains a GridTemplateColumn which has the following RadAjaxPanel:


 

 

<telerik:RadAjaxPanel ID="RadAjaxPanel1" RestoreOriginalRenderDelegate="false" runat="server">

 

 

 

<asp:LinkButton ID="linkbuttonShowHide" runat="server" Text="Show Group Questions"

 

 

 

Font-Size="xx-small" Visible="false" CommandArgument='<%# Eval("QID") %>'

 

 

 

OnCommand="linkbuttonShowHide_Command" CommandName="Click" />

 

 

 

<asp:Panel ID="panel" Visible="false" runat="server">

 

 

 

<asp:GridView ID="gridview1" Visible="true" CssClass="tablescale" runat="server"

 

 

 

ShowHeader="false" ShowFooter="false" AutoGenerateColumns="false">

 

 

 

<Columns>

 

 

 

<asp:BoundField DataField="id" Visible="true" />

 

 

 

<asp:BoundField DataField="text" Visible="true" HtmlEncode="false" />

 

 

 

</Columns>

 

 

 

</asp:GridView>

 

 

 

</asp:Panel>

 

 

 

</telerik:RadAjaxPanel>



when the grid is first loaded the panel is not visible, then when the linkbutton is clicked it is opened with roughly the following code:

 

 

 

protected void linkbuttonShowHideRRQuests_Command(object sender, CommandEventArgs e)

 

{

 

 

LinkButton _lbShowRR = (LinkButton)sender;

 

 

 

GridView _gvRR = (GridView)((LinkButton)sender).Parent.FindControl("gridview1");

 

 

 

Panel _panelRR = (Panel)((LinkButton)sender).Parent.FindControl("panel");

 

 

 

if (_lbShowRR.Text != "Show Questions")

 

{

_lbShowRR.Text =

 

"Show Questions";

 

_gvRR.DataSource =

 

null;

 

_gvRR.DataBind();

 

 

 

 

_panelRR.Visible =

 

false;

 

}

 

 

else

 

 

 

 

 

{

_lbShowRR.Text =

 

"Hide Questions";

 

_gvRR.DataSource =

 

this.GroupQuestions;

 

_gvRR.DataBind();

 

 

 

 

_panelRR.Visible =

 

true;

 

}

 

 

 

 

}

When I add code to export the grid to excel where:
 

 

RadGrid.ExportSettings.ExportOnlyData =

 

true;

 

RadGrid.ExportSettings.IgnorePaging =

 

true;

 

RadGrid.ExportSettings.OpenInNewWindow =

 

true;

I am binding the data in the OnNeedDataSource event of the grid.

The issue I am having is that when RestoreOriginalRenderDelegate="false", the panel will not open, but when RestoreOriginalRenderDelegate="true", the panel will open but the export does not work correctly, I get the

 

Object reference not set to an instance of an object.

error that I have seen in a few other posts. 

I have looked at a few posts and have tried setting the inheritance of the page to the RadAjaxPage and also try to implement IRadAjaxPage, none of this seems to work. 

Is there any other work arounds where both can happen, I can export to excel and I can open the panel within the ajax panel?

Thanks for your help!

Aaron

 

 

 

 

 

 

 

 

 

1 Answer, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 07 Oct 2011, 02:06 PM
Hello Aaron,

RestoreOriginalRenderDelgate property should only be used when if application is running in medium trust environment. If you need to export RadGrid from within ajaxified container (or when the export control is ajaxfied), please examine the following link:
Export from Ajaxified Grid
Code library project

Regards,
Daniel
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Tags
Grid
Asked by
Aaron
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Share this question
or