I have a RadGrid which displays precisely how I want it to. But when I click the button to export to Excel, the button (and also the Refresh button) disappears, along with the entire command item bar. Other RadGrids on the site work fine, but copying their settings to mine still makes the command item bar disappear. Here is one of the RadGrids, with a data source:
<telerik:RadGrid ID="rgPickedDetail" runat="server" AllowFilteringByColumn="False" AllowPaging="True" OnItemCommand="rgPickedDetail_ItemCommand"
AllowSorting="True" DataSourceID="DetailDataSource" ShowStatusBar="True" PageSize="15" OnItemDataBound="rgPickedDetail_ItemDataBound"
Skin="Telerik" AllowAutomaticUpdates="true" AutoGenerateColumns="False">
<ExportSettings HideStructureColumns="true" Excel-Format="Xlsx" ExportOnlyData="true" IgnorePaging="true" />
<PagerStyle Mode="NextPrevNumericAndAdvanced"></PagerStyle>
<MasterTableView CommandItemDisplay="Top" HierarchyLoadMode="ServerOnDemand" AllowSorting="false" AutoGenerateColumns="false" DataKeyNames="SerialNum">
<CommandItemSettings ShowExportToCsvButton="false" ShowExportToExcelButton="true" ShowAddNewRecordButton="false" ShowRefreshButton="true" />
<Columns>
<telerik:GridBoundColumn DataField="Plant" DataType="System.String" HeaderText="Plant" ReadOnly="True" UniqueName="Plant" />
<telerik:GridBoundColumn DataField="PartNum" DataType="System.String" HeaderText="Part" ReadOnly="True" UniqueName="PartNum" />
<telerik:GridBoundColumn DataField="SerialNum" DataType="System.String" HeaderText="Serial number" ReadOnly="True" UniqueName="SerialNum" />
<telerik:GridBoundColumn DataField="QtyPicked" DataType="System.Int32" HeaderText="Picked" ReadOnly="True" UniqueName="QtyPicked" />
<telerik:GridBoundColumn DataField="QtyReq" DataType="System.Int32" HeaderText="Requested" ReadOnly="True" UniqueName="QtyReq" />
<telerik:GridBoundColumn DataField="Scanned" DataType="System.DateTime" DataFormatString="{0:M/d/yy HH:mm}" HeaderText="Scanned" ReadOnly="True" UniqueName="Scanned" />
<telerik:GridBoundColumn DataField="FromLoc" DataType="System.String" HeaderText="From" ReadOnly="True" UniqueName="FromLoc" />
<telerik:GridBoundColumn DataField="ToLoc" DataType="System.String" HeaderText="To" ReadOnly="True" UniqueName="ToLoc" />
<telerik:GridBoundColumn DataField="Picked" DataType="System.Boolean" Display="false" HeaderText="Picked (invisible)" UniqueName="Picked" />
</Columns>
</MasterTableView>
</telerik:RadGrid>
<asp:SqlDataSource runat="server" ID="DetailDataSource" ConnectionString="<%$ ConnectionStrings:TasksConnectionString %>"
SelectCommandType="StoredProcedure" SelectCommand="GetPickReportDetailData">
<SelectParameters>
<asp:Parameter Name="StartDate" DbType="Date" DefaultValue="" />
</SelectParameters>
</asp:SqlDataSource>
The code-behind I think is irrelevant, but what do I know? I can't get it to work correctly. So here it is:
Protected Sub rgPickedDetail_ItemDataBound(sender As Object, e As GridItemEventArgs)
If e.Item.GetType() Is GetType(GridDataItem) Then
Dim item As GridDataItem = e.Item
item.ForeColor = IIf(item("Picked").Text = "True", Color.Green, Color.Red)
End If
End Sub
Protected Sub StartDate_SelectedDateChanged(sender As Object, e As Calendar.SelectedDateChangedEventArgs)
ReportDate = e.NewDate
SetReportDate()
rgPickedDetail.Rebind()
End Sub
Private Sub SetReportDate()
DetailDataSource.SelectParameters("StartDate").DefaultValue = ReportDate
End Sub
Protected Sub rgPickedDetail_PageIndexChanged(sender As Object, e As GridPageChangedEventArgs)
rgPickedDetail.Rebind()
End Sub
Protected Sub rgPickedDetail_PageSizeChanged(sender As Object, e As GridPageSizeChangedEventArgs)
rgPickedDetail.Rebind()
End Sub
Protected Sub rgPickedDetail_ItemCommand(sender As Object, e As GridCommandEventArgs)
If e.CommandName = "ExportToExcel" Then
' I found this executes as expected, and THEN the command bar disappears
End If
End Sub
In case one is trying to build this for a minimum reproducible code, here is the date picker:
<telerik:RadDatePicker RenderMode="Lightweight" Skin="Telerik" ID="StartDate" runat="server" DateInput-Label="Date:" TimePopupButton-Visible="false"
AutoPostBackControl="Both" Calendar-AutoPostBack="false" DateInput-AutoPostBack="true" OnSelectedDateChanged="StartDate_SelectedDateChanged"
DateInput-DateFormat="M/d/yyyy"/>
My research points to conflicts with Ajax, but I have no Ajax in my code, nor in the Site.master file. I have tried putting this RadGrid, with all associated code, onto a page with a working, exportable RadGrid, but THIS RadGrid still doesn't export.
I appreciate any assistance. Thanks!
It turns out I had to add and/or update some DLLs in my site:
Telerik.Windows.Documents.Spreadsheet.dll
Telerik.Windows.Documents.Spreadsheet.FormatProviders.OpenXml.dll
Telerik.Web.UI.dll
Telerik.Web.UI.Skins.dll
The code itself is apparently fine.