Export to Excel from RadGrid inside RadWindow

3 posts, 1 answers
  1. Richard
    Richard avatar
    4 posts
    Member since:
    Feb 2015

    Posted 29 Apr 2015 Link to this post

    We have several pages where we have successfully exported RadGrid contents to Excel using the ExportToExcel() method.  However, we now have a situation where we have a multi-page wizard using a MultiView controls and one of the View controls has a RadGrid on it with a preview of some results.  The users would like to be able to export this RadGrid to Excel.  However, the typical code does not work:


            protected void ExportToExcelButton_Click(object sender, EventArgs e)
                PreviewGrid.ExportSettings.IgnorePaging = true;
                PreviewGrid.ExportSettings.OpenInNewWindow = true;

    The RadGrid is fairly simple:


    <telerik:RadGrid ID="PreviewGrid" AutoGenerateColumns="False" 
                        runat="server" Width="730px" Height="362px">
            <Selecting EnableDragToSelectRows="false"/>
            <Scrolling AllowScroll="true" UseStaticHeaders="True"></Scrolling>
        <MasterTableView DataKeyNames="Key" NoMasterRecordsText="Nothing would be generated." CommandItemDisplay="Top" >
                <div class="floatRightDiv" style="margin-top: 3px;margin-left: 700px;display:none;">
                    <asp:Button ID="ExportToExcelButton" runat="server" CssClass="rgExpXLS" OnClick="ExportToExcelButton_Click" Visible="false"/>
                <telerik:GridBoundColumn UniqueName="Field1" DataField="Field1" HeaderText="Field1"></telerik:GridBoundColumn>
                <telerik:GridBoundColumn UniqueName="Field2" DataField="Field2" HeaderText="Field2"></telerik:GridBoundColumn>
                <telerik:GridBoundColumn UniqueName="Field3" DataField="Field3" HeaderText="Field3"></telerik:GridBoundColumn>
                <telerik:GridBoundColumn UniqueName="Field4" DataField="Field4" HeaderText="Field4"></telerik:GridBoundColumn>
                <telerik:GridBoundColumn UniqueName="Field5" DataField="Field5" HeaderText="Field5"></telerik:GridBoundColumn>
                <telerik:GridBoundColumn UniqueName="Amount" DataField="Amount" HeaderText="Amount" DataFormatString="{0:N2}" ItemStyle-HorizontalAlign="Right" HeaderStyle-HorizontalAlign="Right"></telerik:GridBoundColumn>


    How can we export from a grid in a window?

  2. Answer
    Marin Bratanov
    Marin Bratanov avatar
    3555 posts

    Posted 30 Apr 2015 Link to this post

    Hello Richard,

    There was an issue when exporting a grid within an iframe (or RadWidow) when a RadMenu was also on the page: http://feedback.telerik.com/Project/108/Feedback/Details/118199-fix-radgrid-exporting-inside-an-iframe-radwindow-when-radmenu-is-present-on-the. Could you check if this is your case as well and if so - whether the solution provided in the page above helps? The issue should be resolved in later releases, so I would advise upgrading to the latest (Q1 2015 SP1 at the time of writing) and see if this helps.

    Another common reason for such a problem is AJAX - if the grid is configured to perform AJAX requests, you would not be able to receive the exported file because of the way partial rendering works: http://www.telerik.com/help/aspnet-ajax/grid-export-with-ajax-enabled.html.

    I just tried the scenario (I only had to make the button available on the page) and things seemed to work fine for me.

    Thus, If neither of the above ideas help, I advise opening a ticket and sending us a small, runnable sample that showcases the issue, so we can debug it. 


    Marin Bratanov

    See What's Next in App Development. Register for TelerikNEXT.

  3. DevCraft R3 2016 release webinar banner
  4. Richard
    Richard avatar
    4 posts
    Member since:
    Feb 2015

    Posted 30 Apr 2015 in reply to Marin Bratanov Link to this post

    Turns out the issue was AJAX-related.  We have the standard onRequestStart code to set_enableAjax(false) on the export button in a MasterPageFile named Default.Master, but these RadWindows utilize Dialog pages that use a MasterPageFile of Dialog.Master.  Dialog.Master was missing the onRequestStart code and ClientEvents settings in its RadAjaxManager.  Now the export is being properly output.

    Thank you for the reply.

Back to Top