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

RadGrid NOT Exporting

3 Answers 170 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Sebastien Desemberg
Top achievements
Rank 1
Sebastien Desemberg asked on 04 Apr 2012, 10:48 AM
Hi,

When I click the 'export to excel' icon, the grid flickers, and nothing happens. My code is like this:

    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" DefaultLoadingPanelID="RadAjaxLoadingPanel1">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadGrid2">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid2" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" MinDisplayTime="1000">
    </telerik:RadAjaxLoadingPanel>
    <telerik:RadGrid ID="RadGrid2" runat="server" AllowPaging="True" OnItemDataBound="RadGrid2_ItemDataBound"
        Width="100%" AllowSorting="True" AutoGenerateColumns="False" ShowStatusBar="True"
        OnInsertCommand="RadGrid2_InsertCommand" OnItemCommand="RadGrid2_ItemCommand"
        OnUpdateCommand="RadGrid2_UpdateCommand" GridLines="None" PageSize="100" AllowFilteringByColumn="True"
        DataSourceID="EntityConference" CellSpacing="0" OnDeleteCommand="RadGrid2_DeleteCommand">
        <ExportSettings FileName="ConferenceRegistrationApplications" 
            IgnorePaging="True">
            <Excel Format="ExcelML" />
        </ExportSettings>
        <MasterTableView EditMode="PopUp" CommandItemDisplay="Top" ItemStyle-VerticalAlign="Top"
            DataKeyNames="RegistrationId" CommandItemSettings-ShowExportToExcelButton="true" com >
            <ItemStyle VerticalAlign="Top" />
<CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>
 
<RowIndicatorColumn FilterControlAltText="Filter RowIndicator column"></RowIndicatorColumn>
 
<ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column"></ExpandCollapseColumn>
            <Columns>
                <telerik:GridEditCommandColumn ButtonType="ImageButton">
                    <HeaderStyle Width="3%" />
                </telerik:GridEditCommandColumn>               
               
                <telerik:GridBoundColumn HeaderText="Title" DataField="Title">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn HeaderText="FirstName" DataField="FirstName">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn HeaderText="Surname" DataField="Surname">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn HeaderText="Organisation" DataField="Organisation">
                </telerik:GridBoundColumn>  
                  <telerik:GridTemplateColumn HeaderText="File">
                    <ItemTemplate>
                        <a href="" runat="server" id="AbstractLink">Open</a>
                    </ItemTemplate>
                </telerik:GridTemplateColumn>            
                <telerik:GridButtonColumn Text="Delete" CommandName="Delete" ButtonType="ImageButton"
                    ConfirmDialogType="RadWindow" ConfirmText="Are you sure to delete" ConfirmTitle="Notification">
                    <HeaderStyle Width="2%" />
                </telerik:GridButtonColumn>
            </Columns>
            <EditFormSettings InsertCaption="New Conference" CaptionFormatString="Edit - {0}" CaptionDataField="RegistrationId"
                EditFormType="Template">
                <EditColumn ButtonType="ImageButton" />
                <PopUpSettings Height="1200px" Width="700px" Modal="true" />
                <FormTemplate>
                    <table width="100%">                     
                        <tr>
                            <td>
                                <b>Title:</b>
                            </td>
                            <td>
                                <asp:DropDownList runat="server" DataSourceID="EntityTitles" DataValueField="TitleText"
                                    DataTextField="TitleText" ID="ddlTitles" AppendDataBoundItems="true">
                                    <asp:ListItem Text="-select-" Selected="True" Value="0"></asp:ListItem>
                                </asp:DropDownList>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <b>FirstName:</b>
                            </td>
                            <td>
                                <asp:TextBox runat="server"   ID="TextBoxFirstName" Text='<%#Bind("FirstName") %>'></asp:TextBox>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <b>Surname:</b>
                            </td>
                            <td>
                                <asp:TextBox runat="server"   ID="tLastName" Text='<%#Bind("Surname") %>'></asp:TextBox>
                            </td>
                        </tr>
                          <tr>
                            <td>
                                <b>PreferedName:</b>
                            </td>
                            <td>
                                <asp:TextBox runat="server"  ID="TextBox1" Text='<%#Bind("PreferedName") %>'></asp:TextBox>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <b>Organisation:</b>
                            </td>
                            <td>
                                <asp:TextBox runat="server"  ID="tOrganisation" Text='<%#Bind("OrganisationName") %>'></asp:TextBox>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <b>Telephone:</b>
                            </td>
                            <td>
                                <asp:TextBox runat="server"  ID="ttelephone" Text='<%#Bind("Telephone") %>'></asp:TextBox>
                            </td>
                        </tr>
                         <tr>
                            <td>
                                <b>Fax:</b>
                            </td>
                            <td>
                                <asp:TextBox runat="server"  ID="TextBox2" Text='<%#Bind("Fax") %>'></asp:TextBox>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <b>Mobile:</b>
                            </td>
                            <td>
                                <asp:TextBox runat="server"  ID="tmobile" Text='<%#Bind("Mobile") %>'></asp:TextBox>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <b>EmailAddress:</b>
                            </td>
                            <td>
                                <asp:TextBox runat="server"  ID="temail" Text='<%#Bind("EmailAddress") %>'></asp:TextBox>
                            </td>
                        </tr>         
                          <tr>
                            <td>
                                <b>Profession:</b>
                            </td>
                            <td>
                                <asp:TextBox runat="server"  ID="TextBox3" Text='<%#Bind("Profession") %>'></asp:TextBox>
                            </td>
                        </tr>      
                          <tr>
                            <td>
                                <b>HPCSANumber:</b>
                            </td>
                            <td>
                                <asp:TextBox runat="server"  ID="TextBox4" Text='<%#Bind("HPCSANumber") %>'></asp:TextBox>
                            </td>
                        </tr>      
                          <tr>
                            <td>
                                <b>PostalAddress:</b>
                            </td>
                            <td>
                                <asp:TextBox runat="server"  ID="TextBox5" Text='<%#Bind("PostalAddress") %>'></asp:TextBox>
                            </td>
                        </tr>      
                          <tr>
                            <td>
                                <b>City:</b>
                            </td>
                            <td>
                                <asp:TextBox runat="server"  ID="TextBox6" Text='<%#Bind("City") %>'></asp:TextBox>
                            </td>
                        </tr>      
                          <tr>
                            <td>
                                <b>Province:</b>
                            </td>
                            <td>
                                <asp:TextBox runat="server"  ID="TextBox7" Text='<%#Bind("Province") %>'></asp:TextBox>
                            </td>
                        </tr>      
                          <tr>
                            <td>
                                <b>Country:</b>
                            </td>
                            <td>
                                <asp:TextBox runat="server"  ID="TextBox8" Text='<%#Bind("Country") %>'></asp:TextBox>
                            </td>
                        </tr>      
                          <tr>
                            <td>
                                <b>PostalCode:</b>
                            </td>
                            <td>
                                <asp:TextBox runat="server"  ID="TextBox9" Text='<%#Bind("PostalCode") %>'></asp:TextBox>
                            </td>
                        </tr>      
                          <tr>
                            <td>
                                <b>SpecialInstructions:</b>
                            </td>
                            <td>
                                <asp:TextBox runat="server"  ID="TextBox10" Text='<%#Bind("SpecialInstructions") %>'></asp:TextBox>
                            </td>
                        </tr>      
                          <tr>
                            <td>
                                <b>Accompany_Title:</b>
                            </td>
                            <td>
                                <asp:TextBox runat="server"  ID="TextBox11" Text='<%#Bind("Accompany_Title") %>'></asp:TextBox>
                            </td>
                        </tr>      
                          <tr>
                            <td>
                                <b>Accompany_FirstName:</b>
                            </td>
                            <td>
                                <asp:TextBox runat="server"  ID="TextBox12" Text='<%#Bind("Accompany_FirstName") %>'></asp:TextBox>
                            </td>
                        </tr>      
                          <tr>
                            <td>
                                <b>Accompany_Surname:</b>
                            </td>
                            <td>
                                <asp:TextBox runat="server"  ID="TextBox13" Text='<%#Bind("Accompany_Surname") %>'></asp:TextBox>
                            </td>
                        </tr>      
                          <tr>
                            <td>
                                <b>Accompany_SpecialInstructions:</b>
                            </td>
                            <td>
                                <asp:TextBox runat="server"  ID="TextBox14" Text='<%#Bind("Accompany_SpecialInstructions") %>'></asp:TextBox>
                            </td>
                        </tr>      
                          <tr>
                            <td>
                                <b>RegistrationType:</b>
                            </td>
                            <td>
                                <asp:TextBox runat="server" ID="TextBox15" Text='<%#Bind("RegistrationType") %>'></asp:TextBox>
                            </td>
                        </tr>      
                          <tr>
                            <td>
                                <b>RegistrationFee:</b>
                            </td>
                            <td>
                                <asp:TextBox runat="server"  ID="TextBox16" Text='<%#Bind("RegistrationFee") %>'></asp:TextBox>
                            </td>
                        </tr>           
                          <tr>
                            <td>
                                <b>PaymentMethod:</b>
                            </td>
                            <td>
                                <asp:TextBox runat="server"  ID="TextBox17" Text='<%#Bind("PaymentMethod") %>'></asp:TextBox>
                            </td>
                        </tr>         
                          <tr>
                            <td>
                                <b>TotalPaymentDue:</b>
                            </td>
                            <td>
                                <asp:TextBox runat="server"  ID="TextBox18" Text='<%#Bind("TotalPaymentDue") %>'></asp:TextBox>
                            </td>
                        </tr>         
                          <tr>
                            <td>
                                <b>Comments:</b>
                            </td>
                            <td>
                                <asp:TextBox runat="server"  ID="TextBox19" Text='<%#Bind("Comments") %>'></asp:TextBox>
                            </td>
                        </tr>         
                          <tr>
                            <td>
                                <b>AttendWelcomeFunction:</b>
                            </td>
                            <td>
                                <asp:TextBox runat="server" ID="TextBox20" Text='<%#Bind("AttendWelcomeFunction") %>'></asp:TextBox>
                            </td>
                        </tr>         
                          <tr>
                            <td>
                                <b>AttendCelebrationDinner:</b>
                            </td>
                            <td>
                                <asp:TextBox runat="server" ID="TextBox21" Text='<%#Bind("AttendCelebrationDinner") %>'></asp:TextBox>
                            </td>
                        </tr>         
                          <tr>
                            <td>
                                <b>Accompany_AttendWelcomeFunction:</b>
                            </td>
                            <td>
                                <asp:TextBox runat="server"  ID="TextBox22" Text='<%#Bind("Accompany_AttendWelcomeFunction") %>'></asp:TextBox>
                            </td>
                        </tr>         
                          <tr>
                            <td>
                                <b>Accompany_AttendCelebrationDinner:</b>
                            </td>
                            <td>
                                <asp:TextBox runat="server"  ID="TextBox23" Text='<%#Bind("Accompany_AttendCelebrationDinner") %>'></asp:TextBox>
                            </td>
                        </tr>                
                          <tr>
                            <td>
                                <b>DaysRegistered:</b>
                            </td>
                            <td>
                                <asp:TextBox runat="server"  ID="TextBox24" Text='<%#Bind("DaysRegistered") %>'></asp:TextBox>
                            </td>
                        </tr>              
                       
                    </table>
                    <table style="width100%">
                        <tr>
                            <td align="right">
                                <asp:Button ID="Button1" Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>'
                                    runat="server" CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'>
                                </asp:Button>&nbsp;
                                <asp:Button ID="Button2" Text="Cancel" runat="server" CausesValidation="False" CommandName="Cancel">
                                </asp:Button>
                            </td>
                        </tr>
                    </table>
                </FormTemplate>
            </EditFormSettings>
        </MasterTableView>
 
<FilterMenu EnableImageSprites="False"></FilterMenu>
 
<HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default"></HeaderContextMenu>
    </telerik:RadGrid>

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 04 Apr 2012, 11:23 AM
Hello Sebastian,

The exporting feature of the control work with regular postbacks only. To bypass the limitation you can wire the OnRequestStart event of the ajax panel or ajax manager, determine whether the target control is ajaxified and explicitly disable its ajax mode to export with regular postback.
JS:
function onRequestStart(sender, args) {
  if (args.get_eventTarget().indexOf("btnExport") >= 0)
    args.set_enableAjax(false);
}
Also here is the following help documentation which explains the same.
Export from Ajaxified Grid.

Thanks,
Shinu.
0
Sebastien Desemberg
Top achievements
Rank 1
answered on 04 Apr 2012, 12:00 PM
I put in that Javascript  like this:
<script type="text/javascript">
    function onRequestStart(sender, args) {
        if (args.get_eventTarget().indexOf("ExportToExcelButton") >= 0)
            args.set_enableAjax(false);
    }
</script>


But it still doesnt work. I tried putting the script above and below the grid, both dont work.
0
Shinu
Top achievements
Rank 2
answered on 05 Apr 2012, 02:14 PM
Hi,

When you are exporting from a built-in export button in a CommandItem, you need to replace "btnExport" from the above code snippet with the server ID of the export button as follows.

JS:
<script type="text/javascript">
function OnRequestStart(sender, args)
   {
    if (args.get_eventTarget().indexOf("ExportToExcelButton") >= 0)
     args.set_enableAjax(false);
   }
</script>

Take a look into the following documentation for more information.
Export from Ajaxified Grid

Thanks,
Shinu.
Tags
Grid
Asked by
Sebastien Desemberg
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Sebastien Desemberg
Top achievements
Rank 1
Share this question
or