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
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
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
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
Thank you! That was exactly the assistance I needed!
Celeste