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

Export to Excel button not showing after CommandTemplateItem added

4 Answers 928 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Celeste
Top achievements
Rank 1
Celeste asked on 08 Dec 2010, 09:15 PM

 

Dear Forum.

I added a button to a command item template in my grid and now only the command item template is showig and not the Export to Excel button. I need both buttons to show, please advise.

Thanks,
Celeste

<
CommandItemSettings ShowExportToExcelButton="true" ShowAddNewRecordButton="false" ShowRefreshButton="false" />

 

 

<CommandItemTemplate>

 

 

<asp:Button ID="btnExpandAll" Text="Expand All" Runat="server" CommandName="ExpandAll"></asp:Button>

 

 

</CommandItemTemplate>

 

4 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 08 Dec 2010, 10:46 PM
Hello Celeste,

You have to choose between the template and the built-in command item. It is possible to mimic the built-in buttons when using the commanditem template - here is how:
<CommandItemTemplate>
    <table class="rcCommandTable" width="100%">
        <td>
            <asp:Button ID="Button1" runat="server" Text=" " CssClass="rgExpCSV" CommandName="ExportToCSV" />
            <asp:Button ID="Button2" runat="server" Text=" " CssClass="rgExpPDF" CommandName="ExportToPdf" />
        </td>
        <td style="float: right">
            <asp:Button ID="Button3" runat="server" Text=" " CssClass="rgAdd" CommandName="InitInsert" />
        </td>
    </table>
</CommandItemTemplate>

Regards,
Daniel
the Telerik team
Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Celeste
Top achievements
Rank 1
answered on 09 Dec 2010, 02:28 PM

Daniel,

Well, that doesn't work at all for me. The export doesn't happen, Excel never opens after the RadGrid1.MasterTableView.ExportToExcel();
call and after returning to the page, the CommandItemTemplate line has disappeared.

Here is the markup and code:

<CommandItemTemplate >
   <asp:Button ID="btnExpandAll" Text="Expand All" Runat="server" CommandName="ExpandAll"></asp:Button>
   <asp:Button runat="server" ID="btnExcelExport" CommandName="ExportToExcel" Text="Export to Excel"  />                          
 </CommandItemTemplate> 

  protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e)
        {
            if (e.CommandName == Telerik.Web.UI.RadGrid.ExportToExcelCommandName)
            {
                RadGrid1.MasterTableView.GridLines = GridLines.Both;
                RadGrid1.ExportSettings.OpenInNewWindow = true;
                RadGrid1.ExportSettings.ExportOnlyData = true;
                RadGrid1.ExportSettings.IgnorePaging = true;

                foreach (GridItem commandItem in RadGrid1.MasterTableView.GetItems(GridItemType.CommandItem))
                {
                    commandItem.Visible = false;
                }
                RadGrid1.MasterTableView.ExportToExcel();
            }
}
Thanks,
Celeste

0
Accepted
Daniel
Telerik team
answered on 09 Dec 2010, 10:46 PM
Hello Celeste,

Judging by your explanation I suppose you are trying to export from ajaxified RadGrid. If this is so, please visit the following link:
Export from ajaxified grid

Kind regards,
Daniel
the Telerik team
Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Celeste
Top achievements
Rank 1
answered on 10 Dec 2010, 02:44 PM
Daniel,

Thank you! That was exactly the assistance I needed!

Celeste
Tags
Grid
Asked by
Celeste
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Celeste
Top achievements
Rank 1
Share this question
or