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

Embedded "export to excel button" is disappeared

2 Answers 295 Views
Grid
This is a migrated thread and some comments may be shown as answers.
George
Top achievements
Rank 1
George asked on 23 Sep 2011, 09:41 AM
Hello,

I would like to save all the records of the shipped orders radgrid with rows drag and drop feature to the database. So, i created a LinkButton using CommandItemTemplate like this: 

ASPX:
<CommandItemTemplate>
<
asp:LinkButton ID="LinkButton1" CommandName="UpdateChanges" runat="server">Update all</asp:LinkButton>
</
CommandItemTemplate>


But, as i observed,  the embedded "export to excel button" i had created according to this example for saving all my records to an excel file was disappeared. How could i fix this problem;

P.S.

I used the following sample of code:

ASPX:
<CommandItemTemplate> 
    <asp:ImageButton ID="ExportToExcel" runat="server" OnClick="ExportToExcel_Click" /> 
</CommandItemTemplate> 


CS:
protected void ImageButton2_Click(object sender, ImageClickEventArgs e) 
    { 
        RadGrid1.ExportSettings.ExportOnlyData = true;
        RadGrid1.ExportSettings.IgnorePaging = true;
        RadGrid1.ExportSettings.OpenInNewWindow = true;
        RadGrid1.MasterTableView.ExportToExcel(); 
    } 

But i couldn't fire the events OnExcelMLExportRowCreated and OnExcelMLExportStylesCreated anymore.

Thank you very much.

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 23 Sep 2011, 11:49 AM
Hello George,

Please make sure that you have set the the Excel format as ExcelML.

C#:
RadGrid1.ExportSettings.Excel.Format = Telerik.Web.UI.GridExcelExportFormat.ExcelML;
Also I recommend you examine the following link:
ExcelML basics.

Thanks,
Princy.
0
George
Top achievements
Rank 1
answered on 23 Sep 2011, 12:06 PM
Thank you very much Princy,

I added the line of code you suggested but i still can't fire the events OnExcelMLExportRowCreated and OnExcelMLExportStylesCreated

This is the aspx code of my radgrid:
<telerik:RadAjaxPanel ID="RadAjaxPanel" runat="server" LoadingPanelID="RadAjaxLoadingPanel1"
                 ClientEvents-OnRequestStart="requestStart">
                 <telerik:RadGrid runat="server" AllowPaging="True" ID="RadGrid1" OnNeedDataSource="RadGrid1_NeedDataSource"
                     Width="350px" OnRowDrop="RadGrid1_RowDrop" AllowMultiRowSelection="True"
                     CellSpacing="0" GridLines="None" OnExcelMLExportRowCreated="RadGrid1_ExcelMLExportRowCreated"
                     OnExcelMLExportStylesCreated="RadGrid1_ExcelMLExportStylesCreated">
                    <%-- <ExportSettings ExportOnlyData="true" IgnorePaging="true" OpenInNewWindow="true"
                         FileName="">
                         <Excel Format="ExcelML" />
                     </ExportSettings>--%>
                     <MasterTableView DataKeyNames="BroadcastId" Width="100%" CommandItemDisplay="TopAndBottom"
                         EditMode="InPlace" UseAllDataFields="true">
                             <CommandItemSettings  ShowRefreshButton="false" ExportToPdfText="Export to PDF" ShowExportToExcelButton="true">
                         </CommandItemSettings>
                         <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column">
                         </RowIndicatorColumn>
                         <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column">
                         </ExpandCollapseColumn>
                         <Columns>
                             <telerik:GridDragDropColumn HeaderStyle-Width="18px" Visible="false">
                                 <HeaderStyle Width="18px"></HeaderStyle>
                             </telerik:GridDragDropColumn>
                         </Columns>
                         <NoRecordsTemplate>
                             <div style="height: 30px; cursor: pointer;">
                                 No items to view</div>
                         </NoRecordsTemplate>
                         <EditFormSettings>
                             <EditColumn FilterControlAltText="Filter EditCommandColumn column">
                             </EditColumn>
                         </EditFormSettings>
                         <PagerStyle Mode="NumericPages" PageButtonCount="4" />
                         <CommandItemTemplate>
                             <a href="javascript:void(0);" onclick="ToggleEditSelected('<%= RadGrid1.ClientID %>', this);">
                                 Edit selected</a>
                             <asp:LinkButton ID="LinkButton1" CommandName="UpdateChanges" runat="server">Update all</asp:LinkButton>
                             <asp:Button ID="btnExcelExport" runat="server" Text="Export to Excel" OnClick="btnExcelExport_Click" />
                         </CommandItemTemplate>
                     </MasterTableView>
                     <ClientSettings AllowRowsDragDrop="True" AllowColumnsReorder="True" ReorderColumnsOnClient="True">
                         <Selecting AllowRowSelect="True" EnableDragToSelectRows="False" />
                         <Scrolling AllowScroll="True" UseStaticHeaders="True" />
                     </ClientSettings>
                     <FilterMenu EnableImageSprites="False">
                     </FilterMenu>
                     <HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default">
                     </HeaderContextMenu>
                 </telerik:RadGrid>
             </telerik:RadAjaxPanel>


Thank you very much.
Tags
Grid
Asked by
George
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
George
Top achievements
Rank 1
Share this question
or