Declined
Last Updated: 20 Jan 2015 16:13 by ADMIN
Mads
Created on: 06 Mar 2013 09:44
Category: UI for ASP.NET AJAX
Type: Bug Report
0
export to excel from Radgrid when using Radbutton and AjaxManager
I am having an issue exporting data from a Radgrid when using a Radbutton. Even though I disable the AjaxManager from the code behind the Radgrid wound't export the data. However if I click the button a second time the export window opens, but the file doesn't contain any data. Is there some easy work around in order to fix this issue. If I completely remove the AjaxManager the problem is solved, but makes the usage and layout of the site bad. 

Here is my code...

ASPX:
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" >
    <ClientEvents OnRequestStart="RequestStart" OnResponseEnd="ResponseEnd" />
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="btn_Search">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RG_DataList" LoadingPanelID="ContentLoadingPanel" />
                    <telerik:AjaxUpdatedControl ControlID="datePickersBar" />
                    <telerik:AjaxUpdatedControl ControlID="btn_Export" UpdatePanelRenderMode="Inline" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="btn_Export">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
     </telerik:RadAjaxManager>

<div class="datePickers" id="datePickersBar">
			    <span class="sText">Select period from: </span>
			    <telerik:RadDatePicker ID="RDP_StartDate" runat="server" Culture="da-DK" 
                    HiddenInputTitleAttibute="Visually hidden input created for functionality purposes." 
                    WrapperTableSummary="Table holding date picker control for selection of dates." >
                        <Calendar UseRowHeadersAsSelectors="False" UseColumnHeadersAsSelectors="False" ViewSelectorText="x" runat="server"></Calendar>

                        <DateInput DateFormat="dd-MM-yyyy" DisplayDateFormat="dd-MM-yyyy" AutoPostBack="false" LabelWidth="40%" runat="server" ></DateInput>

                        <DatePopupButton ImageUrl="" HoverImageUrl=""></DatePopupButton>
			    </telerik:RadDatePicker>
			    
			 <span class="sText">to: </span>
		        <telerik:RadDatePicker ID="RDP_FinishDate" runat="server" 
                    Culture="da-DK" 
                    HiddenInputTitleAttibute="Visually hidden input created for functionality purposes." 
                    
                    WrapperTableSummary="Table holding date picker control for selection of dates." >
                        <Calendar UseRowHeadersAsSelectors="False" UseColumnHeadersAsSelectors="False" ViewSelectorText="x"></Calendar>

                        <DateInput DisplayDateFormat="dd-MM-yyyy" DateFormat="dd-MM-yyyy" LabelWidth="40%" ></DateInput>

                        <DatePopupButton ImageUrl="" HoverImageUrl=""></DatePopupButton>
			    </telerik:RadDatePicker>
                &nbsp;&nbsp;&nbsp;&nbsp;
                <telerik:RadButton ID="btn_Search" runat="server" Text="Search" 
                    onclick="btn_Search_Click" Skin="Black" >
                </telerik:RadButton>
                &nbsp;&nbsp;&nbsp;&nbsp;
                <telerik:RadButton ID="btn_Export" runat="server" Text="Export" Skin="Black" 
                    Enabled="false" Visible="true" onclick="btn_Export_Click" 
                    AutoPostBack="true" >
                </telerik:RadButton>
		    </div>
	    
	    <div class="content">
		    <asp:Panel runat="server" ID="Content">
                <telerik:RadAjaxLoadingPanel runat="server" ID="ContentLoadingPanel" 
                        IsSticky="True" CssClass="ajaxLoader" MinDisplayTime="500" 
                        EnableSkinTransparency="False" Skin="Black" />
                <telerik:RadGrid ID="RG_DataList" runat="server" Skin="Default" 
                    onprerender="RG_DataList_PreRender" >
                    <MasterTableView >
                        <CommandItemSettings ShowExportToExcelButton="true"></CommandItemSettings>
                    </MasterTableView>
                    <ExportSettings HideStructureColumns="true" ExportOnlyData="true" IgnorePaging="true" OpenInNewWindow="true">
                        <Excel Format="Biff"></Excel>
                    </ExportSettings>
                    <FilterMenu EnableImageSprites="False"></FilterMenu>
                </telerik:RadGrid>
            </asp:Panel>
	    </div>

CS:
protected void btn_Search_Click(object sender, EventArgs e)
    {
        mergeDataTable();
        btn_Export.Enabled = true;
    }

rotected void btn_Export_Click(object sender, EventArgs e)
    {
        RadAjaxManager1.EnableAJAX = false;

        RG_DataList.ExportSettings.ExportOnlyData = true;
        RG_DataList.ExportSettings.IgnorePaging = true;
       // RG_DataList.ExportSettings.OpenInNewWindow = true;
        RG_DataList.MasterTableView.ExportToExcel();
    }
1 comment
ADMIN
Milena
Posted on: 20 Jan 2015 16:13
Please use the approach demonstrated in the following help article in order to export from ajaxified grid:
http://www.telerik.com/help/aspnet-ajax/grid-export-with-ajax-enabled.html